Resultset as output-parameter
From: Klaus (anonymous_at_discussions.microsoft.com)
Date: 06/03/04
- Next message: David Portas: "Re: SQL Result to Temp Table?"
- Previous message: Joe Celko: "Re: Select using short-circuit condition and breaking after first match"
- In reply to: Klaus: "Resultset as output-parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 3 Jun 2004 06:50:02 -0700
Hi
Just in case anyone else needs to return a query-
resultset from a sp as an output-parameter.
A work-around could be something like this:
CREATE TABLE test (c1 int, c2 varchar(15))
go
-- INSERT INTO test VALUES (1, 'test1') go INSERT INTO test VALUES (2, 'test2') -- CREATE PROCEDURE sp_test @cursor CURSOR VARYING OUTPUT AS SET @cursor = CURSOR FOR SELECT * FROM test OPEN @cursor go -- DECLARE @cursor CURSOR, @c1 INT, @c2 VARCHAR(15) CREATE TABLE #temp_test (c1 int, c2 varchar(15)) EXEC sp_test @cursor OUTPUT FETCH NEXT FROM @cursor INTO @c1, @c2 WHILE @@fetch_status = 0 BEGIN INSERT INTO #temp_test VALUES (@c1, @c2) FETCH NEXT FROM @cursor INTO @c1, @c2 END CLOSE @cursor -- SELECT * FROM #temp_test -- DROP PROCEDURE sp_test go DROP TABLE #temp_test go DROP TABLE test go //Klaus >-----Original Message----- >Hi all > >Is it possible to create a stored procedure, that returns >a resultset (from a select contained in the sp) as a >output parameter. > >If yes, could anyone please provide me with a simple >example. > >TIA >Klaus >. >
- Next message: David Portas: "Re: SQL Result to Temp Table?"
- Previous message: Joe Celko: "Re: Select using short-circuit condition and breaking after first match"
- In reply to: Klaus: "Resultset as output-parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|