If I have stored procedure A which calls stored procedure B to do an insert and return the ID of the inserted record, can I create a Table variable in stored procedure B, fill that Table variable using OUTPUT and then retrieve the value in that Table variable in the calling stored procedure (A) to use as a parameter to pass to stored procedure C? Or would I need to declare the table variable in the calling stored procedure and send it as an out parameter when calling the second stored procedure i.e.
Does that make sense or am I making it too difficult?
Thanks!
wb
Code:
create procedure A
AS
BEGIN
DECLARE @InsertedId TABLE (ID int)
EXEC B @SomeID, @InsertedId OUTPUT
DECLARE @NewId in = SELECT ID FROM @InsertedId
Exec C @NewId
END
create procedure B @SomeId int, @InsertedId int OUTPUT
AS
BEGIN
insert into table
OUTPUT Inserted.Id @InsertedId
select * from someothertable
END
Does that make sense or am I making it too difficult?
Thanks!
wb