Connecting Tech Pros Worldwide Forums | Help | Site Map

IDENT_CURRENT help

Newbie
 
Join Date: Jul 2008
Posts: 3
#1: Aug 17 '08
I am using IDENT_CURRENT to get the id of a record from a table and using it somewhere else (for data insertion, updating). I understand that this not correct from a multi-user perspective since another user can access the same table and all hell can break loose.

My question is this :
If I surround the SQL code using all my inserts and updates with transactions will it guarantee that data will not be corrupted?

eg.

BEGIN TRANSACTION Blah

// SQL code using IDENT_CURRENT

IF @@ERROR > 0
BEGIN
ROLLBACK TRANSACTION Blah
RETURN 99
END

COMMIT TRANSACTION Blah


I will appreciate help on this.

Thank you

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Aug 18 '08

re: IDENT_CURRENT help


I think you should be fine. But a rigid testing of your app could prove me wrong.

-- CK
Reply