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 |
|
mark1504
Posting Yak Master
103 Posts |
Posted - 2005-05-05 : 09:54:31
|
| Can somebody clarify for me. I want to select data with an WHERE CHARINDEX('A','MyField')>0 ORDER BY CHARINDEX('A','MyField')In the instance above it would sort by line with the earliest instance of A in MyField i.e.ABHGEAESDARAEDSWARWSQUANEWUANHEJUAKYHGEA Actually, all the above works fine, I'm pretty happy with it. The question is whether this will read from an index if I create an index for Myfield. I read somewhere that it couldn't, which seemed strange, and I can't figure out a way of testing the fact. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-05-05 : 10:12:50
|
look at the execution plan of your query and you'll see what you use.use northwind select CUSTOMERID, orderdatefrom ordersWHERE CHARINDEX('VI', CUSTOMERID)>0order by CHARINDEX('VI', CUSTOMERID)will use a clustered index scan.Go with the flow & have fun! Else fight the flow |
 |
|
|
mark1504
Posting Yak Master
103 Posts |
Posted - 2005-05-05 : 10:30:46
|
| Oh my god! I've never used the execution plan before, or even heard of it. That's one of the down-sides of being self taught and self employed. I've just looked it up and tried it! No conclusion yet, except that I've just got a new toy to play with :-)Thank |
 |
|
|
|
|
|