Ofcourse, possible. You can pass the other values for the second table to the stored procedure.
Consider this SP. In this, @value3 and @value4 will go to second table.
------------------------------------------------------------------------------
CREATE PROCEDURE sp_insert_record(@value1 varchar(50), @value2 INT, @value3 varchar(50), @value4 varchar(50))
AS
INSERT INTO table1(val1, val2) VALUES (@value1, @value2)
DECLARE @id INT
SELECT @id=@@IDENTITY
INSERT INTO table2(fk_field, val3, val4) VALUES(@id, @value3, @value4)
------------------------------------------------------------------------------
However, when there are a large number of fields, this will be cumbersome.Then you can better get back the id from first SP and then run a second SP to insert into second table.
|