T-SQL out of order insert
- by tearman
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.