Hi all i’m looking for a way to pass in a generated id from a sproc to another sproc.
i.e.
@name varchar(12), @descript varchar(55) @test_date date, @test_result varchar(1) BEGIN EXEC ts_create_item @name, @descript END if (@test_date is not null) or (isnull(@test_result_id,'')!='') BEGIN Exec ts_update_test_results @itemid(generated from the sproc before), @test_date, @test_result End
Is there a way to do this in sql server?
Thanks
Use an output variable
so you would declare the previous proc like
And remember, OUTPUT has to be specified both when declaring and assigning the parameter ie.
Alternately you can use a local variable to hold the result
e.g.