Passing Tables to Stored Procedures

Sometimes we need to pass a table as a parameter to the sproc – For some reason I always forget how, so here it is…

DECLARE @temptable AS UserDefinedTableTypeOrTable
INSERT INTO @temptable ([ColumnName]) VALUES ('MyValue')

EXEC   [dbo].[SprocName]
             @Parameter1 = @temptable,
             @Parameter2 = null,
             @Parameter3 = 0

Leave a Reply

Your email address will not be published. Required fields are marked *