MS SQL Cursor data as result of stored procedure

Posted by Dmitry Borovsky on Stack Overflow See other posts from Stack Overflow or by Dmitry Borovsky
Published on 2010-04-04T13:02:45Z Indexed on 2010/04/04 13:13 UTC
Read the original article Hit count: 238

Hello, I have some stored procedure

DECLARE cursor FOR SELECT [FooData] From [FooTable];
OPEN cursor ;  
FETCH NEXT FROM cursor INTO @CurrFooData;
WHILE @@FETCH_STATUS = 0
BEGIN
  SELECT @CurrFooData AS FooData;
  INSERT INTO Bar (BarData) VALUES(@CurrFooData);
  FETCH NEXT FROM cursor INTO @CurrFooData;
END;
CLOSE OldestFeeds
DEALLOCATE OldestFeeds

But in result I have a lot of tables, not one. How can I return one table with 'FooData' column and all '@CurrFooData' rows?

© Stack Overflow or respective owner

Related posts about sql

Related posts about stored-procedures