Make sure you put the RAISERROR and ROLLBACK TRANSACTION in a BEGIN END
block, or it will always ROLLBACK.
ex.
Don't do..
IF <<condition>>
RAISERROR('You are a Bonehead!',10,1)
ROLLBACK TRANSACTION
this will do the RAISERROR if the condition is met, but will always do the
ROLLBACK TRANSACTION
Do this...
IF <<condition>>
BEGIN
RAISERROR('You are a Bonehead!',10,1)
ROLLBACK TRANSACTION
END
--
Darren Brinksneader
MCDBA, MCSE, CCDA, MCT, CTT+, CCA, CNE
Chief Technologist
A Technological Advantage, Inc.
"Tumurbaatar S." <tu...@datacom.mn> wrote in message
news:#Z2K8N$9BHA.1516@tkmsftngp02...
TKS
"Tumurbaatar S." <tu...@datacom.mn> escribió en el mensaje
news:#Z2K8N$9BHA.1516@tkmsftngp02...
Is it recommended to ROLLBACK manually in the trigger, or to RAISERROR
with a severity of 19-25?
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
[Please remove "nospam_" from email address to reply.]
Severity of 19 will still process the delete (if no ROLLBACK is there).
Severity of 20 - 25 will break the connection. (Make sure you specify WITH
LOG with the RAISERROR).
So, I say ALWAYS!!! (just in case you put the wrong severity level)
HTH
--
Darren Brinksneader
MCDBA, MCSE, CCDA, MCT, CTT+, CCA, CNE
Chief Technologist
A Technological Advantage, Inc.
"Brandon Lilly" <blilly@nospam_medevolve.com> wrote in message
news:u#PbGuF#BHA.1868@tkmsftngp04...
...some Transact-SQL expression, e.g. SELECT/UPDATE/INSERT/DELETE/EXEC...
SET @err = @@ERROR
IF @err <> 0
BEGIN
RAISERROR(@err, 16, 1) WITH SETERROR
ROLLBACK TRANSACTION
RETURN
END
In this case, about half of my script code repeats
above check block. What do you think I do unnecessary
thing?
"Darren Brinksneader" <dbrink...@nospam.atai.com> wrote in message
news:#rrcsRB#BHA.2308@tkmsftngp02...
INS...
IF @@ERROR <> 0 GOTO ERR
UPD...
IF @@ERROR <> 0 GOTO ERR
DEL...
IF @@ERROR <> 0 GOTO ERR
RETURN
ERR:
RAISERROR...
ROLLBACK
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Tumurbaatar S." <tu...@datacom.mn> wrote in message news:#r3uLEM#BHA.2040@tkmsftngp04...