Is it possible to return or output a @tableVariable in SQL Server?
For example for the following stored procedure, how do I return the @TSV table variable?
ALTER PROCEDURE MyStoredProdecure
@Parameter1 INT,
@Parameter2 INT
AS
BEGIN
DECLARE @TSV TABLE
(
Transition_Set_Variable_ID INT,
Passed BIT
)
INSERT INTO @TSV
{ some data }
END
You cannot do it directly. Table variables are valid for READONLY input.
If you have no other data being returned from the stored procedure, you can select from the @TSV at the end and have the caller capture the output, e.g.
Caller
Alternatively, if the SP is really as simple as you showed, turn it into a table valued function instead.