sql 触发器
时间:2011-12-15
来源:互联网
A表中有a1,a2,a3和a4列,分别表示款号,色号,尺码,状态(有两种状态审核和未审核,默认是未审核)
B表中有b1,b2,b3和b4列,分别表示款号,色号,尺码,状态
当A表中的状态变成审核时,把A中对应这一行的数据插入导B表中
要求用触发器实现
B表中有b1,b2,b3和b4列,分别表示款号,色号,尺码,状态
当A表中的状态变成审核时,把A中对应这一行的数据插入导B表中
要求用触发器实现
作者: liyaohui13098452233 发布时间: 2011-12-15
SQL code
create tigger test on a for update,insert as begin if update(状态) insert into b select * from inserted i where not exists(select 1 from b where 款号=i.款号) end
作者: fredrickhu 发布时间: 2011-12-15
SQL code
create tigger test on a for update,insert as begin if update(状态) and (select 状态 from inserted)='审核' insert into b select * from inserted i where not exists(select 1 from b where 款号=i.款号) end
作者: ssp2009 发布时间: 2011-12-15
SQL code
create tigger trig_test on A表 for update as if update(状态) and exists(select 1 from inserted where 状态='审核') insert into B表 select * from inserted
作者: geniuswjt 发布时间: 2011-12-15
引用 1 楼 fredrickhu 的回复:
SQL code
create tigger test on a
for update,insert
as
begin
if update(状态)
insert into b select * from inserted i where not exists(select 1 from b where 款号=i.款号)
end
. SQL code
create tigger test on a
for update,insert
as
begin
if update(状态)
insert into b select * from inserted i where not exists(select 1 from b where 款号=i.款号)
end
作者: jiangzhong610 发布时间: 2011-12-15
SQL code
create tigger inserttbA on 表A for update,insert as begin if update(状态) and (select 状态 from inserted)='审核' insert into 表B select * from inserted end
作者: qianjin036a 发布时间: 2011-12-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28