jsmith
jsmith

Reputation: 575

SQL parameterization

I'm writing a sql query for an SSRS report and wanted to paramterize the @startdate and @endate fields for the user to specify. Yet when I put my query into SSRS, the user input is ignored. I was wondering if it had to do with the fact that I wasn't assigning to a parameter but comparing to it?

These are my declaration statements:

DECLARE @startdate NVARCHAR(10)
DECLARE @enddate NVARCHAR(10)

And this is my where clause:

WHERE assignees.id = customers.id
AND 

((dateadd(second,open_date,'19700101') >= @startdate
AND dateadd(second,open_date,'19700101') <= @enddate)

OR

(dateadd(second,close_date,'19700101') >= @startdate
AND dateadd(second,close_date,'19700101') <= @enddate))

AND group_name = 'SPRQ'

Upvotes: 0

Views: 73

Answers (1)

Rose
Rose

Reputation: 156

Instead of using character types for date comparisons, I would suggest using date types for more reliable, predictable results. Also, check the parameters property of the dataset to be sure it shows the report parameter used to fill the query parameter. Sometimes the designer needs "reminded" which report parameter to use for the query's parameteer.

Upvotes: 1

Related Questions