Home Forums SQL Server 2008 T-SQL (SS2K8) Select Only Rows with Alphabetical Character in Column RE: Select Only Rows with Alphabetical Character in Column

  • To make sure the you won't have a problem in the future with strings like 'SomeString1' or any other mix of characters including symbols especially in some of the collations available, etc, try the following (added test data to that which was already posted)...

    WITH SomeData(SomeValue) AS

    (

    SELECT '1.51922e+015' UNION ALL

    SELECT '1.53122e+015' UNION ALL

    SELECT 'FMCIT' UNION ALL

    SELECT 'ABCNP' UNION ALL

    SELECT 'FMCPNG' UNION ALL

    SELECT '1.62073e+015' UNION ALL

    SELECT '1.6127e+015' UNION ALL

    SELECT 'A+B' UNION ALL

    SELECT 'A.B' UNION ALL

    SELECT 'A B' --Space between letters

    )

    SELECT *

    FROM someData

    WHERE SomeValue NOT LIKE '%[^A-Za-z]%' COLLATE LATIN1_GENERAL_BIN

    ;

    --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)