Removing repeated duplicated characters

后端 未结 6 1413
醉酒成梦
醉酒成梦 2021-02-08 12:12

I have a string in my stored proc like \',,,sam,,bob,\' or \',,,\' from the above string I have to delete multiple commas from it, it must look like <

6条回答
  •  广开言路
    2021-02-08 13:13

    try this

    SELECT @Parameter AS 'BEFORE'
    BEGIN
    WHILE CHARINDEX(',,', @Parameter) > 0
        BEGIN
            SELECT @Parameter = REPLACE(@Parameter, ',,',',') 
        END
    SELECT @Parameter AS 'AFTER'
    END
    

提交回复
热议问题