>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.


Posted on January 20, 2011, in Sql Server 2005, Sql Server 2008, Tables, TSQL Tips n Tricks. Bookmark the permalink. 3 Comments.

  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 regularlyhttp://supernsetips-news.blogspot.com=================================================

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: