MichaelMcDonald
Posts: 640
|
Posted: 01/09/2015, 12:30 AM |
|
Does anyone have a working solution which does not use @@identity ?
_________________
Central Coast, NSW, Australia.
|
|
|
eratech
Posts: 513
|
Posted: 01/17/2015, 5:23 PM |
|
Michael - sorry no. I've used the @@identity. Only change is if I need the ID back I will put it in a stored proc so I can handle new or updates in same code and just return the appropriate ID (new or existing)
But still boils down to @@identity.
Is there a problem that you are finding with @@identity?
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 02/02/2015, 1:28 PM |
|
I have read that if the table is linked to another and a stored procedure exists to insert a record into the other table that @@identity could return the foreign key.
_________________
Central Coast, NSW, Australia.
|
|
|
eratech
Posts: 513
|
Posted: 02/02/2015, 5:01 PM |
|
Hmmm - I haven't heard that one about the foreign keys. Do you have a reference as I have a large MSSQL DB with lots of stored procs and I'd like to check.
I know there was (might still be) some possible errors with web apps and sessions getting mixed up with multiple inserts but that was rare anyway.
I *have* seen a weirdness with the IDENTITY setting on a table jump 10,000-ish numbers after a server re-start. The answer from MS was that the IDENTITY would be unique and incremented, but not necessarily sequential. Wasn't a huge deal but we lost about 10k possible member numbers.
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 02/02/2015, 6:20 PM |
|
just found the answer ...
@@identity can be a problem ...
http://blog.sqlauthority.com/2007/03/25/sql-server-iden...tity-of-record/
_________________
Central Coast, NSW, Australia.
|
|
|
|