like '%' does not accept NULL value

Well, how about

SELECT 
  * 
FROM 
  [table] 
WHERE
  ([table].[column] like <parameter>) OR 
  (<parameter> = '%')

...so that when you pass '%', you get all the rows back, otherwise it works like you have it at the moment.


I think this might work:

Select * From [table] Where [table].[column] is null or [table].[column] like '<parameter>'

isnull([table].[column], '') like '%'

Works like a charm


You can use coalesce to treat null like an empty string:

where COALESCE([table].[column],'') like '<parameter>'

On SQL Server, you can also use IsNull:

where IsNull([table].[column],'') like '<parameter>'

Tags:

Sql

Null