Tag Info

New answers tagged

1

You could use a try ... catch block: -- Create test table if object_id('YourTable') is not null drop table YourTable create table YourTable (id int identity); -- Safeguarded insert set identity_insert YourTable on; begin try insert YourTable (id) values (100); -- this generates an exception declare @oops int = cast('a' as int) end try ...


1

I believe your best bet is going to be to use a TRY-CATCH. I've done two things here. First declare and get your "oldID" before your transaction begins. This will help to keep your transaction time down and avoid deadlocks as much as possible. Second I've put the "core" of the rest of it into a TRY block and then in the CATCH block put the reseed again. ...



Top 50 recent answers are included