MS SQL Cursor data as result of stored procedure
- by Dmitry Borovsky
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?