[求助]如何使用触发器
有那位仁兄知道在SQLServer2000中的触发器怎么整阿,给个网站也可以
CREATE TRIGGER trigger_name
ON { table | view
}
[ WITH ENCRYPTION ]
{
{
{
FOR | AFTER | INSTEAD OF
} { [ INSERT ] [ , ] [ UPDATE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS
[ { IF UPDATE ( column )
[ { AND | OR } UPDATE ( column ) ]
[ ...n ]
| IF ( COLUMNS_UPDATED ( )
{ bitwise_operator
} updated_bitmask )
{ comparison_operator
} column_bitmask [ ...n ]
} ]
sql_statement [ ...n ]
}
}
示例
当 titles 表更改时,下例将电子邮件发送给指定的人员 (MaryM)。
USE pubsIF EXISTS (SELECT name FROM sysobjects WHERE name = 'reminder' AND type = 'TR') DROP TRIGGER reminderGOCREATE TRIGGER reminderON titlesFOR INSERT, UPDATE, DELETE AS EXEC master..xp_sendmail 'MaryM', 'Don''t forget to print a report for the distributors.'GO
不好意思, 示例搞的不好看了, 再来一次:
使用带有提醒电子邮件的触发器
当 titles 表更改时,下例将电子邮件发送给指定的人员 (MaryM)。
USE pubsIF EXISTS (SELECT name FROM sysobjects WHERE name = 'reminder' AND type = 'TR') DROP TRIGGER reminderGOCREATE TRIGGER reminderON titlesFOR INSERT, UPDATE, DELETE AS EXEC master..xp_sendmail 'MaryM', 'Don''t forget to print a report for the distributors.'GO