Thursday, January 20, 2011

SQL Server: How to Insert Stored Procedure Result Set in a Table

Tables can be populated with data from result set of stored procedure. Method can be applied to regular, temporary and global temporary tables but table variables can not be populated in this fashion.

INSERT INTO [YourTableName](CommaSeparatedColumnsName)
 EXECUTE YourStoredProcedureNameHere CommaSeparatedParameterValues

 Note: Number of input and output columns, as well as their datatypes must be same.


  1. I am regular visitor of blogs, but i must say that content which i find in your blog is outstanding.i will love to visit your blog regularly


  2. How do you get around the error "An INSERT EXEC statement cannot be nested." which inevitably occurs?



All suggestions are welcome