> Hi:
>
[quoted text clipped - 12 lines]
> WHERE (TS_CREATEDATE) >= @CreateDate OR TS_NAME LIKE '%' + @ReportName
> + '%'
You should do a couple of things. Firstly, you will probably want to
have some sort of default value for both parameters (i.e., empty
string (' '), N/A or 1/1/1900). That way the report itself will not
error out. Secondly, you will want to ignore the defaults in the
query, something like:
IF (TS_CREATEDATE != '1/1/1900' AND TS_NAME != 'N/A')
SELECT TS_ID, TS_NAME AS [Report Name], TS_CREATEDATE
FROM REPORTS
WHERE (TS_CREATEDATE) >= @CreateDate AND TS_NAME LIKE '%' +
@ReportName + '%'
ELSE IF (TS_CREATEDATE = '1/1/1900' AND TS_NAME != 'N/A')
SELECT TS_ID, TS_NAME AS [Report Name], TS_CREATEDATE
FROM REPORTS
WHERE TS_NAME LIKE '%' + @ReportName + '%'
ELSE
SELECT TS_ID, TS_NAME AS [Report Name], TS_CREATEDATE
FROM REPORTS
WHERE (TS_CREATEDATE) >= @CreateDate
Hope this helps.
Regards,
Enrique Martinez
Sr. SQL Server Developer