insert from exec

Posted on 2012-03-19
Last Modified: 2012-03-19
Is it possible to have an insert statement but using

exec sp_selecttable
Question by:sevensnake77
  • 2
  • 2

Author Comment

ID: 37738440
So example would be

Insert Into [table1]

exec sp_selecttable
LVL 39

Assisted Solution

lcohan earned 300 total points
ID: 37738601
Yes, you must create the table first matching the record set from your SP so assume your SP returns

id int, name varchar(50), address varchar(100)

you create atable like:

create #temp_table (id int, name varchar(50), address varchar(100));
insert into #temp_table exec sp_whatever;
LVL 39

Accepted Solution

lcohan earned 300 total points
ID: 37738612
Sorry one minor syntax error above and you can do the same with a permanent database table not just temporary table:

create table #temp_table (id int, name varchar(50), address varchar(100));
insert into #temp_table exec sp_selecttable;

Author Closing Comment

ID: 37738667

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Restore Procedure question 4 31
SQL Mirror and Replication 5 26
Trouble with References... 5 25
BULK INSERT most recent CSV 19 21
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now