sql server 2005 - C# : Is there any C# function to insert primary key from one table into another -
i have 2 tables in want insert data 1 after another. primary key of first table in 2nd. there c# function can insert primary key of first table @ 1 go, without select query?
you can accomplish stored procedure performs both inserts , returns identity value caller.
create procedure procedure1 begin declare @id int; insert [table1] (col1) values ('foo'); set @id = scope_identity(); insert [table2] (col1, col2) values (@id, 'bar'); return @id; end
Comments
Post a Comment