Here is what I have and I think it works:
insert totals (date_stamp, KWH )
select dateadd( day, datediff( day, 0, getdate() ), -1 ),
(
(select
KWH
from
Daily
where
D1.Date_Stamp = dateadd( day, datediff( day, 0, getdate() ), -1 ))
+
(select...
I have a table called "Daily" (Daily data) that looks like this:
DateStamp KWH
11/6/2005 1867
11/7/2005 2001
11/8/2005 2023
.
.
A second table called "15_min" (15 minute data) looks like this:
[DateTime] KW
11/8/2005 00:00 am 201
11/8/2005 00:15 am 198
...
I have this code that displays the results of a select query:
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit%>
<HTML>
<body>
<%
' Open Database connection
'***********************************************
DIM objConn, dbname, data_source
Set objConn = Server.CreateObject("ADODB.Connection")...
Here is how I got it to work, in case some body is interested in this later.
CREATE PROCEDURE [Proc1]
@strDateVariable varchar(50)
AS
Exec('SELECT DateTime1 , TotalKWH FROM table1 WHERE DateTime1 > convert(datetime,''' + @strDateVariable + ''', 101)')
Notice that the DateVariable is passed...
Oops, Sorry guys!!.It does not work yet.
It does not generate errors, but the query does not produce the correct results.
I am basically getting the entire table. So basically the condition TimeStamp > '1/1/2005' is not evaluating correctly.
The '1/1/2005', which is passed as a string to the...
Thank you all for all the valuable hints. you pointed me in the right direction.
I got it to work by doing this in the ASP code:
DateVariable = "'01/01/2005'"
objRs.Open "Execute Proc1 " & strTableName & ", " & strColumn & " ," & DateVariable, objConn
The change I made to the stored...
I am getting the following error when I ran it in query analyzer:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '•'.
Apparantly it doesn't like the way the date variable is formatted?
In the ASP page I set the DateVariable as follows:
DateVariable = "1/1/2005"
And I am getting an error at this line:
objRs.Open "Execute Proc1 " & strTableName & ", " & strColumn & " ," & DateVariable, objConn
It says:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1...
I have some ASP code that looks like this:
objRs.Open "Execute Proc1 " & strTableName & ", " & strColumn , objConn
The Stored procedure "Proc1" looks like this:
CREATE PROCEDURE [Proc1]
@strTable varchar(50),
@strColumn varchar(50)
AS
Exec('SELECT ' + @strColumn + ' FROM ' + @strtable + '...
How can I pass DateTime Paramter to stored procedure from within an ASP page? Can you give me an example - or maybe point me to a link where this is explained?
Thanks
Thanks for the hint. And sorry for posting two questions in one thread. I will leave this thread just for how to pass multiple paramters to Stored procedure.
In the ASP page I do the following:
oRs.Open "Execute sp_Proc " & strTable & ", " & strColumn , conn
In the Stored procedure, I would...
I have an ASP page with this code:
strTable = "table1"
oRsSubs.Open "Execute sp_Proc " & strTable, conn
The stored procedure in SQL looks like this:
CREATE PROCEDURE sp_Proc ( @strTable varchar(50) )
AS
EXEC('SELECT * FROM ' + @strTable)
This work fine. I am trying however to add some...
Sorry I got side-tracked.
Yes your method works fine. I did this in the ASP page:
oRs.Open "Exec spSelectAll " & sName, conn
The stored procedure is as outlined above.
Thanks for the help
I have an ASP page that contains a database table name as a string variable, i.e "strTableName".
I need to pass this string form the ASP page to a SQL stored procedure. The sp will execute something like:
select * from @strTableName
The results will be retured to the ASP in a record Set.
How...
Great!!. It works just fine.
I changed it to "between 8 and 19", as vongrunt has suggested. This is because "between" is inclusive or "closed ended".
Thanks a lot!
I have a SQL View called "KWH_Daily", and it’s driven by a 15 minutes table called "KW_15min"
The 15-min table has data in 15-min intervals, i.e.:
[DateTime] KW
9/13/2005 11:00 am 300
9/13/2005 11:15 am 304
9/13/2005 11:30 am 298
The Daily View (KWH_Daily) is constructed by using the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.