March 26, 2011 at 8:27 pm
Create Procedure
{
@LastName Varchar(100) = null
}
as
select * from TBS_Names where (@LastName is null or lastname = @LastName)
go
But, before you go with this approach, also please read this blog about performance issues that may result from plan caching: http://blogs.msdn.com/b/bartd/archive/2009/05/03/sometimes-the-simplest-solution-isn-t-the-best-solution-the-all-in-one-search-query.aspx
March 26, 2011 at 11:48 pm
Hi SunitaBeck,
Thanks for the help. The reference you have mentioned was extremely good!
Thanks
March 27, 2011 at 3:24 am
Read through this as well: http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/. sunitabeck's solution does not perform well on larger resultsets.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply