CREATE TRIGGER 名1 ON t1
FOR INSERT
AS
insert t3 select id,name,account from inserted where id not in (select id from t3)
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名2 ON t1
FOR update
AS
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名3 ON t1
FOR delete
AS
update t3 set account=t3.account-aa.account from inserted aa where t3.id=aa.id
FOR INSERT
AS
insert t3 select id,name,account from inserted where id not in (select id from t3)
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名2 ON t1
FOR update
AS
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名3 ON t1
FOR delete
AS
update t3 set account=t3.account-aa.account from inserted aa where t3.id=aa.id
解决方案 »
- 不能将NULL插入iIndex
- 求一条updatesql语句。希望你们能进来帮帮我。谢谢你们了。
- MS Sql Server数据库dba有没有什么认证?
- sql server 2000 数据库连接?
- 在线等,关于数据库记录的问题
- 在查询分析器中还原数据库备份的时候,如何同时修改逻辑文件名?
- 如何将一个表中的一列组合到一个字符串中?
- 谁可以帮我解决哈sql预编译出错,网上查不到!!!
- sql 查询表中的所有信息(字段名是英文,我想让注释来代替)
- 紧急求助:我这条sql procedure中的语句可不可以实现对cursor记录集中每条语句的修改?
- 触发器的一个小问题
- 可以在存储过程中执行:create database @db_name;吗?
FOR INSERT
AS
update t3 set account=t3.account-aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名2 ON t2
FOR update
AS
update t3 set account=t3.account+aa.account from deleted aa where t3.id=aa.id
update t3 set account=t3.account-aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名3 ON t2
FOR delete
AS
update t3 set account=t3.account+aa.account from deleted aa where t3.id=aa.id
CREATE TRIGGER 名1 ON t1
FOR INSERT
AS
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名2 ON t1
FOR update
AS
update t3 set account=t3.account-aa.account from deleted aa where t3.id=aa.id
update t3 set account=t3.account+aa.account from inserted aa where t3.id=aa.id
CREATE TRIGGER 名3 ON t1
FOR delete
AS
update t3 set account=t3.account-aa.account from deleted aa where t3.id=aa.id
你写的就是利用id这个字段来判断是吗?
还有t3表上没有数据也可以吗?
是还有t3表上没有数据也可以吗?
是