Groups | Blog | Home
all groups > sql server programming > january 2004 >

sql server programming : Check another table before delete trigger


David Portas
1/12/2004 11:10:17 PM
CREATE TRIGGER trg_xyz
ON Sometable FOR DELETE
AS
IF EXISTS
(SELECT *
FROM Some_Other_Table AS T
JOIN Deleted AS D
ON T.colx = D.colx)
BEGIN
ROLLBACK TRAN
RAISERROR('RI Violation',16,1)
END

--
David Portas
------------
Please reply only to the newsgroup
--

Lasse
1/12/2004 11:47:03 PM
Hi, On delete of a record I would like to check if a certain record in
another table is present, if it is I would like the delete to be cancelled.
Is that possible in a trigger ? How would that trigger code look like ? (I
cant use relationship integrity)

Lasse

AddThis Social Bookmark Button