Stored Procedure that has table argument in T-SQL

后端 未结 1 1827
日久生厌
日久生厌 2021-01-26 17:42

Table Argument as OUTPUT

I want to pass a table variable into a procedure that has table argument as output, but not as read only! I want to be able to modify that arg

相关标签:
1条回答
  • 2021-01-26 18:23

    You'd have to copy the table valued parameter into a table variable or temp table

    CREATE PROC DoStuff
        @tvp SomeTableType READONLY
    AS
    ..
    SELECT * INTO #LocalCopy FROM @tvp; -- take local copy
    ...
    DoStuff -- do processing on the input
    ...
    SELECT ... FROM LocalCopy;  --return results to client
    GO
    

    After comment, a table valued parameter can not be declared OUTPUT. From CREATE PROC

    A table-value data type cannot be specified as an OUTPUT parameter of a procedure.

    0 讨论(0)
提交回复
热议问题