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 |
|
pottersfield
Starting Member
2 Posts |
Posted - 2006-06-06 : 12:26:06
|
| Hi folks.I have a simple query along the lines of:SELECT Fieldname FROM tblFoo WHERE Street LIKE 'Street Name %'Street is a non-clustered index. The table is about seven million rows.When I run the query with 'Street Name %' as a literal string in the query, it comes up in under a second.When I put 'Street Name %' into a varchar(50) local variable and put that in the query...it takes over two minutes.The environment is SQL2K, on SP4 as far as I know (waiting for confirmation on that).Can anyone offer suggestions? You'd save my co-workers from a certain amount of pacing and snarling. Thanks very much. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-06 : 12:29:02
|
| Try giving an index hint.SELECT Fieldname FROM tblFoo (index = myindex)WHERE Street LIKE 'Street Name %'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
pottersfield
Starting Member
2 Posts |
Posted - 2006-06-07 : 05:23:36
|
| sorted - thank you! |
 |
|
|
|
|
|