Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 search performance query inquiry
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Arab Emirates
3 Posts

Posted - 02/06/2013 :  06:03:36  Show Profile  Reply with Quote
Hi All,
if we have to search on all the columns of a table which option is better
1. ColumnA like '%SearchVal%' OR ColumnB like '%SearchVal%' OR ColumnC like '%SearchVal%'
2. Concatentate (ColumnA+ColumnB+ColumnC) like '%SearchVal%'


James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/06/2013 :  07:48:00  Show Profile  Reply with Quote
Run both and compare the execution plans. I suspect both may be just about the same. Neither would be able to make use of any indexes, so all 3 columns in every row will need to be scanned. The remaining effort of concatenating or comparing would be minimal.

The thing to keep in mind with the second query is that if some of the values happen to be null in one or more of the columns, the result you get can be different from the result you get with the first query.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000