Edited to account for NULL parameter valuesdeclare @t table (parameter int, col varchar(10))insert into @t (parameter, col)select 0, 'a' union allselect 1, 'b' union allselect 2, 'c' union allselect null, 'd'declare @parameter intselect @parameter = 0select * from @t where (@parameter = 0 and isnumeric(isnull(parameter, 0))=1)OR (@parameter != 0 and parameter = @parameter)
Some days you're the dog, and some days you're the fire hydrant.