Insert Into, Append, Temp Table ?

  • I have two columns, name & keywords

    How can I change the following SQL statement so that it will append data

    onto the end of the keywords column so that it reads "current info+the new

    set info below" instead of overwriting the current data ?

    SET KEYWORDS = 'soap, ice, snow'

    WHERE (NAME LIKE '%drink%')

  • Try this.

    DECLARE @KeyWords VARCHAR(1000)

    DECLARE @NewKeyWOrds VARCHAR(1000)

    DECLARE @Name VARCHAR(100)

    SELECT @KeyWords = (SELECT KeyWords FROM Table WHERE Name = @Name)

    UPDATE TABLE SET KeyWords = @KeyWords + @NewKeyWords

    WHERE Name = @Name


    Kindest Regards,

  • That worked good.

    Thanks for the help.

  • This could also have been done like this...

    UPDATE Foo

    SET Keywords = Keywords + @NewKeywords

    WHERE...




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply