|
-
March 27th, 2014, 07:12 PM
#3
Re: SQL current ID check returns same value twice.
Point taken. I agree, nevertheless it does seem like a strange behaviour, having IDENT_CURRENT return the same value twice.
If an insert error occurs the procedure will return with error and I will catch it, thus knowing that it went wrong and doing whatever I need to do. The ID will be skipped and the SQL engine will return the next ID when asked. An "empty" ID will then exist in the DB. The same would happen if I eventually delete a record, its ID will be left unassigned. In any of these cases IDENT_CURRENT would point the last entry and IDENT_CURRENT + IDENT_INCR should be the next to-be-assigned ID... right?
I'm not very skilled with SQL so I really don't know how to write a procedure that will return the ID. I'm betting on a "return ID" line at the end lol and I'm guessing I'd have to change ExecuteNonQuery for ExecuteScalar to get a return value?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|