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 |
|
Sachin.Nand
2937 Posts |
Posted - 2009-12-24 : 05:28:11
|
| [code]create table #tbl (name varchar(40))insert into #tblselect 'abc' union allselect 'def' union allselect 'mns' union allselect 'xyz' create nonclustered index IX_name on #tbl(name)select name from #tbl where name like '[^A-M]%'select name from #tbl where name like '[A-M]%'drop index IX_name on #tbldrop table #tbl[/code]The first query is causing Index scan whill second one is causing Index seek.Can anyone throw light on this?PBUH |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2009-12-24 : 11:33:47
|
Crazy optimizer... Sometimes you can force a seek...select name from #tbl where name like '[A-M]%'select name from #tbl where name like '[^A-M]%' and name > '' |
 |
|
|
|
|
|