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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -