在SQL Server上使用触发器 [英] using trigger on sql server
本文介绍了在SQL Server上使用触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表table1和table2
表1
ID,名称,年龄,日期和序列号
table2
data1和data2
所以我想在table1上使用触发器,如果有人想在table1上插入/更新和删除,那么应该生成一条新消息并将该消息保存到table2中
如果我正在使用触发器,怎么可能...请指导我
i have two tables table1 and table2
Table1
id,name,age, date and serial number
table2
data1 and data2
so i want to use trigger on table1 and if any one wants to insert/update and delete on table1 so a new message should be generate and that message should be save into table2
how it can be possible if i am using trigger .....please guide me
推荐答案
请按照以下链接
http://manuals.sybase.com/onlinebooks/group-as /asg1250e/sqlug/@ Generic__BookTextView/48841; pt = 48717 [ http://stackoverflow.com/问题/5341584/sql-server-after-insert-trigger-update-another-column-in-the-same-table [
Hi, follow below links
http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/48841;pt=48717[^]
http://stackoverflow.com/questions/5341584/sql-server-after-insert-trigger-update-another-column-in-the-same-table[^]
尝试一下:-
Try this:-
1,170,000 results on google for Learning about triggers
Thanks
嘿,
使用此触发器
Hey,
use this trigger
ALTER TRIGGER [dbo].[InsertMessage]
ON [dbo].[Table1]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
insert into table2(data1,data2) values('Message1','Message2')
END
祝你好运
best luck
这篇关于在SQL Server上使用触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文