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

Posted on 2011-05-12
Last Modified: 2012-05-11

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?

Question by:rgcole
    LVL 45

    Accepted Solution

    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,
    LVL 67

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now