View Single Post
  #2 (permalink)  
Old May 27th, 2007, 09:49 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Depending on your requirements, you can check if Column or @Column is null:

WHERE COLUMN LIKE '%' + @Column + '%' OR @Column IS NULL

This example returns all rows when the actual search term (@Column) equals null.

Similarly, you can check the value in the column as well:

WHERE COLUMN LIKE '%' + @Column + '%' OR Column IS NULL

This returns all records where either a match is found with the like operator or where the actual column data is null.

Hope this helps,

Imar




---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.