SQL Server Optional Parameters
Posted on 2014-09-11
I am writing a stored proc for an SSRS report. The user wants the report to bring back all the data on the first run and then allow the user to set 4 parameters. I initially created the report to show nothing until the user selected parameters, but they want all data returned and then filter it out.
I have four parameters @LiveDate datetime = Null, @Status bit = Null,@CarType varchar(30) = NULL,@somethingelse varchar(30) = NULL
Then I have a select statement. It the WHERE clause that I am confused about. If the parameters are NULL, then I want to return everything and if not then return according to the parameter values.
Can someone help me with the WHERE clause here.