Can someone help me with the correct syntax for the following stored procedure query? I am trying to use the following query for a report and it works fine in the report designer's sqldatasource but I have to convert it to a stored procedure.
The Error is: Msg 102, Level 15, State 1, Procedure PricingProcedure, Line 16 Incorrect syntax near 'DateTime'.
and: Msg 137, Level 15, State 2, Procedure PricingProcedure, Line 53 Must declare the scalar variable "@StartDate".
asked Oct 02, 2012 at 05:06 PM in Default
You need to actually declare the variables ie DECLARE @StartDate DATATIME
If you want this as a stored procedure the following will work:
answered Oct 02, 2012 at 05:48 PM
You're getting out of date ranges because of the OR clause:
If you change it to an AND then all three conditions must be true for a result. Right now the first two are taken as one unit and the OR clause is separate.