Reputation: 3451
I have a stored proc returning a set of columns. I want to store the return set into a temp table. I know how to do this: INSERT INTO #TABLE EXEC SP1
Now, the temp table has extra columns that can be NULL. How can I do the same thing and leave the extra columns with NULL values?
Upvotes: 0
Views: 950
Reputation: 69819
Just explicitly list the column names you want to insert to:
INSERT #Table (Column1, Column2, Column3)
EXEC SP1;
Which is something I would advocate doing anyway in production code. Aaron Bertrand has written an excellent article as to why:
Upvotes: 5