What is the comparison I can use to make the code run its fastest?


In a query I want to examine a string.   I want to learn if the string's first position is "1".
So, I want to say if this string's first character is "1" then do something.

I have used either        iif( Left([thevariable],1) = "1",
and I have used           iif( [thevariable] like "1*",

Which of the two statements run faster OR is there another form my comparison can take?

Thanks,
Robert
LVL 9
rgcoleAsked:
Who is Participating?
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi rgcole,

That would depend entirely on the parser, optimizer, and indexing of the underlying DBMS.  But you'd be hard pressed to find a modern DBMS that didn't handle either one quite well.

For most modern optimizers it shouldn't matter.  The call to LEFT will return a single character that the DBMS will handle just as if LIKE '1%' had been used.



Good Luck,
Kent
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.