use casa
GO
CREATE TRIGGER no_delete_admin
ON [dbo].[usuarios]
INSTEAD OF DELETE
AS
IF EXISTS(SELECT * FROM deleted d WHERE d.id = 4)
BEGIN
--ROLLBACK;
RAISERROR('No se puede eliminar',16,1);
END
ELSE
BEGIN
DELETE usuarios WHERE id IN (SELECT id FROM deleted)
END
SELECT * FROM usuarios where id IN (1)
SELECT * FROM deleted d WHERE d.id <> 1
version2
GO
CREATE TRIGGER [dbo].[no_delete_admin]
ON [dbo].[usuarios]
INSTEAD OF DELETE
AS
IF EXISTS(SELECT * FROM deleted d WHERE d.id = 4)
BEGIN
SET ANSI_WARNINGS OFF;
SET ANSI_WARNINGS ON;
--ROLLBACK;
--RAISERROR('No se puede eliminar',16,1);
END
ELSE
BEGIN
DELETE usuarios WHERE id IN (SELECT id FROM deleted)
END