sql - Scope_Identity in Stored Procedure -


i have stored procedure has 3 insert statements. need after each insert want know inserted value of id querying scope_identity.

something following :

insert t1(name)values("david") set @v1=scope_identity()  insert t2(name)values("david2") set @v2=scope_identity()  insert t3(name)values("david3") set @v4=scope_identity() 

is there way that?

create table t1 (id int identity, name varchar(30)) create table t2 (id int identity, name varchar(30))  declare @v1 int, @v2 int  insert t1 (name) values ('david') set @v1 = scope_identity()  insert t2 (name) values ('david2') set @v2 = scope_identity()  select @v1, @v2 

click here see in action @ sql fiddle.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -