|
The following code works perfectly until the datetime between @shiftastart and @shiftaend is added. I have queried the values for both variable and they what I need however when I add the statement I get the following error Must declare the scalar variable "@SHIFTASTART". here is the complete query
(comments are locked)
|
|
Your dynamic SQL statement does not know about your two date variables. You need to pass those values into the sp_executesql statement similar to the following example...
You can review the syntax of sp_executesql in BOL. that worked thank you so much ... i read the books and tried everything i could think of but your code was just enough different to help me undersand
Apr 27 '10 at 07:26 PM
Clint
(comments are locked)
|
|
or just change @sql statement to select @sql = 'select max(datetime), TagName, max(value)as value from v_history where TagName in (' + @tags + ') and datetime between' + @shiftastart + 'and' + @shiftaend + 'group by tagname'
(comments are locked)
|

