• Ok, here we go... Assuming that you have the company name in a variable and the fact that you're using a version of T-SQL that cannot use functions, here's how I'd do it...

    [font="Courier New"]

    --===== Company name is in a variable

    DECLARE @CompanyName VARCHAR(256)

     SELECT @CompanyName 'A & B Cleaners' 

      PRINT @CompanyName --Just for verification... you can remove this line

    --===== Using a "Tally" table as a loop driver, remove all characters that

         -- are NOT in the in range of A to Z (upper or lower case)

     SELECT @CompanyName STUFF(@CompanyName,PATINDEX('%[^A-Z]%',@CompanyName),1,'')

       FROM dbo.Tally t

      WHERE t.N <= LEN(@CompanyName)

        AND SUBSTRING(@CompanyName,t.N,1) LIKE '[^A-Z]'

    --===== Grab just the left six characters of what remains.

     SELECT @CompanyName LEFT(@CompanyName,6)

    --===== Display the result (just for verification... you can remove this line)

      PRINT @CompanyName[/font]

    If you don't have a Tally table, please see the article at the following URL for how to build one, what it is, and how it works. It's a very useful tool that can frequently be used to replace loops.

    http://www.sqlservercentral.com/articles/TSQL/62867/

    If you need to do this to a whole table column, please post back.

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