• Well, primary is question directed to SQL 2005. I'll be more specific:

    --===== If the test table already exists, drop it

    IF OBJECT_ID('TempDB..#mytable','U') IS NOT NULL

    DROP TABLE #mytable

    IF OBJECT_ID('TempDB..#replacements','U') IS NOT NULL

    DROP TABLE #replacements

    --===== Create the test table with

    CREATE TABLE #mytable

    (

    ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,

    LongString nvarchar(max)

    )

    --===== Create table with replacements

    CREATE TABLE #replacements

    (

    code nvarchar(55)

    ,replacement nvarchar(255)

    )

    --===== Add sample data

    INSERT INTO #mytable (LongString)

    select 'code01 something else code02' union all

    select 'code02 code02 aacode01'

    INSERT INTO #replacements

    select 'code01', 'XXXX' union all

    select 'code02', 'YYYY'

    Well, my intention is to write query for select data from #myTable using replacements from #replacements table, i.e. desired output is

    XXXX something else YYYY

    YYYY YYYY aaXXXX

    Hope it's clear, thx in advance for any suggestion.

    Note: I really want to avoid using cursor, while loops, etc. And I really won't use replace(replace(replace(replace(.... query, imagine that #replacements table got 100 records, which could be changed time to time.