Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Maria90
Starting Member
1 Post |
Posted - 2009-03-20 : 09:44:19
|
| I know the different between searching for an exact string with WHERE COLUMN='X' and the flexible LIKE. I would like to know if WHERE COLUMN='X' is more efficient in searching (faster) than LIKE because it doesn't have the same flexibility. I mean if I am searching for an exact string "testString", wouldn't be any difference to use WHERE or LIKE when it comes to performance?Thanks |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-03-20 : 09:57:01
|
| suggest you go thru this,http://www.mssqltips.com/tip.asp?tip=1346 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-03-20 : 10:13:50
|
From: http://bytes.com/groups/ms-sql/159177-like-vs(Erland Sommarskog, SQL Server MVP)It can be virtually difference at all, or it can like night and day.If col is non-indexed, the only overhead is a somewhat more complexcomparison operation.If col is indexed with a non-clustered index, the optimizer will haveto make a decision on whether to use the index. Assume for simplicitythat the index is unique. Then = will use that index, and access will befast. But if there is LIKE there is another story. In this case, thereare two possible strategies: use the index or scan the table. Scanningthe table is better a large proportion of the rows start with 'abc%'.The optimizer does not know about this, but from statistics compiledabout the table, it can make an estimate. If the estimate is incorrect,the plan may not be the best - something the users will very painfullynotice. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|