Answer by Håkan Winther
Look at OUTPUT Clause in books online, that will solve your issues
View ArticleAnswer by Cyborg
Katie, You can use [OUTPUT][1] Clause to achieve this. Eg: Declare @Object2 Table(ID INT) Declare @id int insert into A.object (@id, 'name') select @id = @@IDENTITY from A.object insert into A.object2...
View ArticleAnswer by Matt Whitfield
Just as a separate thing - you really shouldn't use `@@IDENTITY`. `@@IDENTITY` returns 'the last inserted `IDENTITY` value on the connection' - meaning that if you do an insert into a table, and that...
View ArticleAnswer by ThomasRushton
Another side-issue. If you are writing code that's dependent upon this sort of thing, then make sure your schema includes appropriate foreign-key relationships, and wrap up your T-SQL statements in...
View ArticleAnswer by Kev Riley
I might be missing something here, or maybe it's lack of coffee, but aside from the good answers about OUTPUT clause, if the PK on object2 isn't an identity field then I presume you are setting the...
View ArticleAnswer by Håkan Winther
Look at OUTPUT Clause in books online, that will solve your issues
View ArticleAnswer by Cyborg
Katie, You can use [OUTPUT][1] Clause to achieve this. Eg: Declare @Object2 Table(ID INT) Declare @id int insert into A.object (@id, 'name') select @id = @@IDENTITY from A.object insert into A.object2...
View ArticleAnswer by Matt Whitfield
Just as a separate thing - you really shouldn't use `@@IDENTITY`. `@@IDENTITY` returns 'the last inserted `IDENTITY` value on the connection' - meaning that if you do an insert into a table, and that...
View ArticleAnswer by ThomasRushton
Another side-issue. If you are writing code that's dependent upon this sort of thing, then make sure your schema includes appropriate foreign-key relationships, and wrap up your T-SQL statements in...
View ArticleAnswer by Kev Riley
I might be missing something here, or maybe it's lack of coffee, but aside from the good answers about OUTPUT clause, if the PK on object2 isn't an identity field then I presume you are setting the...
View Article
More Pages to Explore .....