August 17, 2009 at 11:42 am
I have an existing sproc that returns 15 fields and I'd like to use this to insert data into a table that only has 10 fields. Is there any way to ignore the extra fields in an Insert statement or do i need to create a new sproc?
TIA
Dean
August 17, 2009 at 11:59 am
Your stored proc returns a result set I assume, so I assume you're asking if you can do something like:
INSERT INTO TABLE (COLUMNS)
EXEC StoredProc
To my knowledge, no, you can't do that. What you can do is create a temp table or table variable, insert it into that table, and then from there, you can insert the values you want into your table.
EG:
DECLARE @TempTable TABLE
(
AllColumnsFromStoredProc
)
INSERT INTO @TempTable (AllColumnsFromStoredProc)
EXEC StoredProc
INSERT INTO RealTable (ColumnsToInsert)
SELECT ColumnsToInsert FROM @TempTable
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy