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 |
Ciupaz
Posting Yak Master
232 Posts |
Posted - 2013-06-11 : 10:19:17
|
Hello all,I have a table like this:ID - FKID - Title1 - Title2 - Value - ModifiedDateNow I have to perform an INSERT in this tablewhere the fields Title1,Title2,Value come from a stored procedure calling, and FKID is a variable in the scope of a stored procedure where this Insert is performed (ModifiedDate is GETUTCDATE()). How can I perform this? Thanks in advance. Luigi |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-06-11 : 10:41:20
|
The first thing that comes to mind - INSERT-EXEC would not work in your case because the columns in the insert part of the statement must exactly match the columns coming out of the EXEC part (the stored proc).You could try open rowset. There are few examples here http://msdn.microsoft.com/en-us/library/ms190312.aspxIf you have not already, you would need to enable Ad Hoc Distributed queriessp_configure 'Show Advanced Options', 1GORECONFIGUREGOsp_configure 'Ad Hoc Distributed Queries', 1GORECONFIGUREGO Another option is to insert the data from the stored proc into a temp table with columns that exactly match the stored procedure record set and then move that into your target table appending the additional columns as required. |
|
|
Ciupaz
Posting Yak Master
232 Posts |
Posted - 2013-06-11 : 11:21:33
|
Maybe the solution with a temporary table could be better. I'll try. Lugi |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|