October 20, 2004 at 12:57 am
Though 'retruning' is a great-sounding word, I think you mean returning? ![]()
Great question - I'm assuming that you're performing an insert to a table with an auto-incrementing PK and want to know what the value of the PK will be, for this inserted record, after insert?
I'd be interested to hear what other people here say - I have always ensured that I have inserted something unique (and known at time of insert) and then done a select query afterwards to determine the value of the new record's PK after insert.
Regards
Phil
October 20, 2004 at 2:10 am
If by 'row id' SQL Server's identity is implied, you can use either of SCOPE_IDENTITY, IDENT_CURRENT, or @@IDENTITY.
They are slightly different in how they work, look up 'SCOPE_IDENTITY' in BOL and read there. There's a good explanation there about the differences.
/Kenneth
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply