• I would add that you can also do it like this:

    --sample data

    SELECT * INTO #test

    FROM (VALUES (1,'blah AAA'),(2,'bbb bbb bbb'),(3,'AAA ccc')) t(id,val);

    SELECT * FROM #test;

    WITH your_table AS

    (

    SELECT * FROM #test WHERE val like '%AAA%'

    )

    UPDATE your_table

    SET val=REPLACE(val,'AAA','[xxx]')

    SELECT *

    FROM #test

    I like this technique because, in SQL Server Management Studio, you can highlight & execute just the SELECT * FROM #test WHERE val like '%AAA%' portion of the statement to see what rows are going to be updated.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001