Walk the string

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping

Q&A for gardeners and landscapers

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

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

Enter Parameters

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