I think there has been some discusions on this topic here on the forums,but I have no links at the moment.I think there are a number of ways to do this, with pros/cons, index usage etc.One basic problem is if you want the user to be able to explicitely search for null columns.(avoid nulls in the database, btw)Here is one basic way:create sproc_dynamicparam @a <datatype> = null ,@b <datatype> = nullasset nocount onselect a,bfrom tblwhere (a = @a or @a is null) and (b = @b or @b is null)
alternative:...where coalesce(@a,a) = a and coalesce(@b,b) = b
rockmoose