Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mcrazyinsano
Starting Member
4 Posts |
Posted - 2009-03-04 : 14:20:21
|
| If anyone can provide insight or guidance on this i would really appreciate it. I am moderately experienced in SQL.I have a database, let's called it DB1 and there is a stored procedure in there. I want to execute the stored procedure with set parameters and then i want the results to be inserted into a table in DB2. My questions are..a) how do i go about getting the results and inserting them into a table in a different database (same server)b) how do i create the table structure on DB2 so it fits exactly with the result setThank you |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-03-04 : 14:31:42
|
| INSERT <db>.<schema>.<targetTable> (<columnList that matches SP output>)exec <db>.<schema>.<StoredProcedure> [<parameter1>, <parameter2>, etc]EDIT:The INSERT column list for the target table needs to be the columns in your table. The output of the SP just needs to match the same number of columns and datatypes, the column names output from the SP doesn't matter. Just order the column list to match the SP output. The order doesn't have to match the physical table column order.Be One with the OptimizerTG |
 |
|
|
mcrazyinsano
Starting Member
4 Posts |
Posted - 2009-03-04 : 15:26:49
|
| Okay, i'll give that a try and let you know. Thanks for the info |
 |
|
|
|
|
|