• How about this?

    ;WITH cte AS

    -- split each string by character and decide UPPER or lower based on previous character or being the first char

    (

    SELECT

    N,

    Id,

    CASE

    WHEN N=1 OR (N>1 AND SUBSTRING(location ,N-1,1 ) = ' ')

    THEN UPPER(SUBSTRING(location ,N ,1))

    ELSE LOWER(SUBSTRING(location ,N ,1))

    END AS split

    FROM Tally

    CROSS APPLY -- apply the code to each location

    ( SELECT Location, min(MyId) AS Id

    FROM Import_Data_Filter

    GROUP BY Location

    )y

    WHERE N < LEN(' ' + location + ' ')

    )

    -- and put it back together

    SELECT

    REPLACE((SELECT '' + split FROM cte c2 WHERE c2.Id = c1.Id ORDER BY N FOR XML PATH('')),' ',' ')

    FROM cte c1

    GROUP BY Id



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]