Quantcast
Channel: Answers for "Obtaining the recently inserted value in an non identity column."
Browsing all 10 articles
Browse latest View live

Answer by Håkan Winther

Look at OUTPUT Clause in books online, that will solve your issues

View Article



Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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


Answer by Håkan Winther

Look at OUTPUT Clause in books online, that will solve your issues

View Article

Answer 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 Article

Answer 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 Article


Answer 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 Article


Answer 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
Browsing all 10 articles
Browse latest View live




Latest Images