Can We Pass Temp Table as Parameter to Stored Procedure

A TEMP Table of User Defined Table Type has to be created of the same schema as that of the Table Valued parameter and then it is passed as Parameter to the Stored Procedure in SQL Server.

How do you pass a temp table to a stored procedure as parameter?

First, you have to define the user defined type for the table variable to be used by the stored procedure. The stored proc can then be called with a table variable directly from SQL. Note: If you are using . NET, then you can pass the SQL parameter from a DataTable type matching the user defined type.

Can we use table variable in stored procedure?

Table Variables Can Be Returned From a SQL Server Function. While table variables can be created in stored procedures, their use is restricted to within the stored procedure declaring the variable.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest