CREATE TRIGGER [Delete_TopAlexa] ON [dbo].[tb_WebSite]
FOR DELETE
AS
BEGIN TRANSACTION
delete from tb_alexa where websiteid=(select websiteid from deleted)
delete from tb_top100 where websiteid=(select websiteid from deleted)
IF (@@ERROR <> 0) -- 如果有错误
BEGIN
ROLLBACK TRANSACTION -- 回滚
END
COMMIT TRANSACTION -- 提交事务
FOR DELETE
AS
BEGIN TRANSACTION
delete from tb_alexa where websiteid=(select websiteid from deleted)
delete from tb_top100 where websiteid=(select websiteid from deleted)
IF (@@ERROR <> 0) -- 如果有错误
BEGIN
ROLLBACK TRANSACTION -- 回滚
END
COMMIT TRANSACTION -- 提交事务