Walk the string

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lifehacks

Q&A for people looking to bypass life's everyday problems with simple tricks

DECLARE @ix INT
DECLARE @value varchar(25)
DECLARE @ProductId varchar(40)
SET @ProductId = '1;2;3;4;5;5;6;'

WHILE PATINDEX('%;%', @ProductId) <> 0
BEGIN
     SELECT  @ix= PATINDEX('%;%',@ProductId)
     SELECT  @value= LEFT(@ProductId, @ix- 1)
     SELECT  @ProductId= STUFF(@ProductId, 1, @ix, '')
     print (@ProductId)
    
END

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results