-1

here is what I have and I want to loop through this set

select value from fxsplitint('1223,123,123',',')

fxsplitint is a function created to split the string on a delimiter

I want to say print each value after I do something with it

mjsqu
  • 5,151
  • 1
  • 17
  • 21
chuckd
  • 13,460
  • 29
  • 152
  • 331

1 Answers1

1

You could use a temp table to iterate through all the values in your list returned by the function.

DECLARE @rowcount int;
DECLARE @i int;
DECLARE @value int;

SET i = 0;

SELECT id = identity(int, 1,1), a.* INTO #yourtemptable FROM (
   SELECT value FROM fxsplitint('1223,123,123',',')
)

WHILE (@i <= @rowcount)
   BEGIN
     SET @value = value FROM #yourtemptable WHERE id = @i;

     SELECT @value; --output your value

     SET @i = @i + 1
   END
DROP TABLE #yourtemptable;
Steve Salowitz
  • 1,283
  • 1
  • 14
  • 28