If Statement to determine WHERE condition in SQL Query



Hello,

The @parameters that I am receiving into my SQL query in SQL Serer 2000
Reporting Services are based on user selection from a drop down combo box.
If the user selects a name it will return an integer. An alternative to
selecting a single name the user can select 'ALL' of which will return a -1
or maybe '*' if allowed. I would like an if stmt to determine if a criteria
be added to the query or not. Can I do this, is there anyway of achieving the
same thing?

SELECT Forename, Username, Description
FROM Audit
WHERE Date >= @Param_StartDate
AND Date < @Param_EndDate
if @Param_UserKey <> -1
AND UserID =@Param_UserKey 'continue to add last line of SQL stmt

There are two more @Parameters to test if the 'ALL' option is selected also
not
sure I can neatly handle this. @Param_RecordType and @Param_ModuleNo.

Thank you kindly for any assistance.

Cheerio
Rhonda
.



Relevant Pages

  • Re: Equivalent of Get Next Extended to retrieve only unique keys?
    ... The only real "extra" stuff is pertaining to SQL query optimization. ... Bill Bach wrote: ... Retaining the ability to filter on multiple>> items would probably ...
    (comp.databases.btrieve)
  • Re: Setting a Default Value
    ... the make the Sql call from within Application_Start in Global.asax. ... the query string value each time I needed to ... going to assign the default value through a database query. ... run the following SQL query: select * from table where x = 1 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SQL RPGLE cursor delete from view? -204
    ... how does the SQL engine know which rowto delete? ... C/exec sql ... i have a huge select statement joining 6 files, with some selection ... C+ fetch PRIOR from C1 into:f1, ...
    (comp.sys.ibm.as400.misc)
  • Re: MultiSelect Property
    ... > For Each vItm In Me!lbSelectContract.ItemsSelected ... > Dim stCriteria As String ... >> SQL query). ... >> the multiselect list box appears in the SQL query. ...
    (microsoft.public.access.devtoolkits)
  • Re: Requery Combo Box
    ... The SQL was generated like you said, ... On the same criteria row for each column add the restrictions ... The user selects a name from the first combo box that has a query behind ... After the selection, ...
    (microsoft.public.access.queries)