Question : Show all records when variable is null

Hi,
I have a query that works and returns records depending on an input variable.
When the input parameter is blank no records are passed back ( and quite correctly so). What I would like to do is the opposite and select all the records as if the parameter filter was not there.

Any suggestions?

Answer : Show all records when variable is null

I prefer doing it this way

select * from yourtable where (@yourparameter is null OR yourcolumn = @yourparameter)

Random Solutions  
 
programming4us programming4us