Alphanumberic string search

  • lmu92 (2/2/2010)


    WayneS (2/2/2010)


    And yet, if you look at the last line of the OPs original post, this is exactly what he wants.... for now.

    So, do you think having a persisted calculated column that moves the last character to the first position of the value would be one of the possible answers that even might help performance?

    That sounds like a good idea.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • BrainDonor (2/2/2010)


    sql_ques (2/2/2010)


    Please tell me how to do it.

    No.

    I will however take as long as is required to help you to work out how to write it. That is how you learn the more fundamental aspects of SQL Server. I can be very patient, as long as you don't give in, as you did with:

    http://www.sqlservercentral.com/Forums/Topic837177-8-1.aspx

    and

    http://www.sqlservercentral.com/Forums/Topic835685-1291-1.aspx

    There are three commands of interest - LEFT, RIGHT and SUBSTRING (probably using LEN, if these values have different lengths).

    Have a look at them and give it some thought. Come back with an attempt at the solution and we'll be happy to help.

    Heh... man... at first I thought you were being really unnecessarily rude. Then I looked at the links you included and found out who the rude one really is. Thanks for the heads-up.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • CirquedeSQLeil (2/2/2010)


    lmu92 (2/2/2010)


    sql_ques (2/2/2010)


    SELECT LASTNAME FROM CPM.dbo.T_CANADIAN

    WHERE '678567' BETWEEN '673001' AND '679000'

    AND 'Z' BETWEEN 'P' AND 'P'

    this worked.

    I actually doubt that this query would return anything but an empty result set.

    Reason:

    The WHERE part "AND 'Z' BETWEEN 'P' AND 'P'" will always be false since 'Z' will never be between 'P' and 'P'.

    Therefore, the whole WHERE condition will result on zero matching rows.

    Just wondering...

    Why not just do

    SELECT LASTNAME FROM CPM.dbo.T_CANADIAN

    WHERE 1 <> 2

    That should provide an empty result set too.

    lol reminds me of http://xkcd.com/221/

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply