• Can you explain a little more?

    if i had THIS as a comment:

    declare @text varchar(4000)

    SET @text = Without a doubt SQLCentral is home to finest SQL folk[comment:#grovel].

    Sometimes things may get heated[comment:#super hot debate].

    But great minds find their way[comment:#method to madness?].

    The rest of us eat Pork Chops[comment:#ha ha:)].'

    do you want to replace all 4 of the comments betweent he brackets with the SAME replacement text?

    from your example, you are just replacing them with an empty string instead?

    it's fairly easy to do, you use a tally table, and find the start and end brackets, then use STUFF to replace the contents. between the two brackets.

    here's a simple way using a WHILE Loop:

    --===== Replace all [' and ']' pairs with nothing

    WHILE CHARINDEX('[',@text ) > 0

    SELECT @text = STUFF(@text ,

    CHARINDEX('[',@text ),

    CHARINDEX(']',@text ) - CHARINDEX('[',@text ) + 1, --1 is the length of the search term

    '')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!