?
Solved

insert from exec

Posted on 2012-03-19
4
Medium Priority
?
423 Views
Last Modified: 2012-03-19
Is it possible to have an insert statement but using

exec sp_selecttable
0
Comment
Question by:Seven price
  • 2
  • 2
4 Comments
 
LVL 9

Author Comment

by:Seven price
ID: 37738440
So example would be

Insert Into [table1]

exec sp_selecttable
0
 
LVL 40

Assisted Solution

by:lcohan
lcohan earned 1200 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;
0
 
LVL 40

Accepted Solution

by:
lcohan earned 1200 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;
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 37738667
tks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

807 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