Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to output table variables back to caller?

Status
Not open for further replies.

rmahawaii

Programmer
Oct 21, 2002
29
HK
Hello, I have a local table variable @tableTmp in my stored procedures. How can I output the whole table variable back to the caller? thanks in advance.
 
Set the table variable as an output parameter rather than a local variable:

Code:
CREATE PROC myproc
  @input1 int,
  @input2 varchar(20),
  @tablevar table (col1 int, col2 varchar(10)) OUTPUT
AS
...

Populate the table as you are already doing in the proc code. Then when calling the proc use:

Code:
DECLARE @t1 table (col1 int, col2 varchar(10))
EXEC myproc 123, 'char data', @t1 OUTPUT

This will give you the built table from the proc in your variable @t1 --James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top