You are here: Re: Like vs = « MsSQL Server « IT news, forums, messages
Re: Like vs =

Posted by Erland Sommarskog on 08/21/05 19:14

--CELKO-- (jcelko212@earthlink.net) writes:
>>> Is there a better to handle three parameters where any combination of
them could be optional? <<
>
> Let the inputs be NULL when missing and coalesce them to empty strings:
>
> WHERE col1 LIKE COALESCE (@param1, '') + '%'
> AND col2 LIKE COALESCE (@param2, '') + '%'
> AND col3 LIKE COALESCE (@param3, '') + '%'

I agree that NULL is better than empty strings from a conceptual point of
view, but performance-wise it will not make things any better.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация