|
Aksaa
Starting Member
United Arab Emirates
3 Posts |
Posted - 02/06/2013 : 06:03:36
|
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%'
regards, Liwiaw |
|
|
James K
Flowing Fount of Yak Knowledge
1497 Posts |
Posted - 02/06/2013 : 07:48:00
|
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. |
 |
|