insert from exec

Is it possible to have an insert statement but using

exec sp_selecttable
LVL 9
Seven priceFull StackAsked:
Who is Participating?
 
lcohanDatabase AnalystCommented:
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;
0
 
Seven priceFull StackAuthor Commented:
So example would be

Insert Into [table1]

exec sp_selecttable
0
 
lcohanDatabase AnalystCommented:
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;
0
 
Seven priceFull StackAuthor Commented:
tks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.