T-SQL out of order insert

Posted by tearman on Stack Overflow See other posts from Stack Overflow or by tearman
Published on 2010-05-17T15:40:07Z Indexed on 2010/05/17 15:50 UTC
Read the original article Hit count: 339

Filed under:
|

Basically I have a User-Defined Table Type (for use as a table-valued variable) which I'm referencing in a stored procedure that effectively just calls two other stored procedures, then inserts those values into the table type.

Id est

INSERT INTO @tableValuedVariable (var1, var2, var3, var4, var5)
         EXEC [dbo].StoredProcedure1;

INSERT INTO @tableValuedVariable (var1, var2, var5)
         EXEC [dbo].StoredProcedure2;

You can probably already tell what I'm going to ask. Basically StoredProcedure2 only returns a few of the values the table is set to hold, and I'd like those other variables to just be null (as defined as default). Only SQL is complaining that I'm not specifying all the variables available to that table.

The return datasets can be quite sizable so I'd like to avoid loops and such for obvious reasons.

Thanks for any help.

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server-2008