You're trying to return the value of multiple select statements in a single stored procedure?
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
How are you viewing the results of the SP? In the query analyzer or in your application? I have tested this concept with the QA and it works fine:
IF OBJECT_ID('sp_GetTablesX', 'P') IS NOT NULL DROP PROCEDURE sp_GetTablesX
--
GO
--
CREATE PROCEDURE sp_GetTablesX
AS
BEGIN
Declare @lServerId int
DECLARE det_cursor CURSOR FOR
Select 1 As Col Union All Select 2 Union All Select 3 --3 sample rows
OPEN det_cursor
FETCH NEXT FROM det_cursor INTO @lServerId
WHILE (@@FETCH_STATUS = 0)
BEGIN
Select @lServerId
FETCH NEXT FROM det_cursor INTO @lServerId
END
CLOSE det_cursor
DEALLOCATE det_cursor
END
--
GO
--
exec dbo.sp_GetTablesX
If you're using an application this is likely a problem in your code or the data adapter when a query returns multiple result cursors. This is not a common task.
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735