第二天,这一百条记录中的数据,有10条记录在ha_com中的statuscd已经变成DA了,
那么test中保留这十条记录,而且所有字段都更新一遍,然后再选择表ha_com 中statuscd <>'DA'的
记录插入到test中,这样的存储得怎么写的
===============
没看明白,不是只更新DA改变的吗?怎么还选择<>DA的插入到test中,DA改变的以外,余下的不都是DA不变的?
你是指第二天又增添了新记录,默认状态<>DA?插入?
那么test中保留这十条记录,而且所有字段都更新一遍,然后再选择表ha_com 中statuscd <>'DA'的
记录插入到test中,这样的存储得怎么写的
===============
没看明白,不是只更新DA改变的吗?怎么还选择<>DA的插入到test中,DA改变的以外,余下的不都是DA不变的?
你是指第二天又增添了新记录,默认状态<>DA?插入?
第一次如果select from ha_com where statuscd <>'DA'有一百条记录插入到
test中,第二次,这一百条记录中的数据,有10条记录在ha_com中的statuscd已经变成DA了,
那么test中保留这十条记录,而且所有字段都更新一遍,然后test中在ha_com状态仍为<>'DA'的删除掉,
然后再选择表ha_com 中statuscd <>'DA'的 或是第一次如果select from ha_com where statuscd <>'DA'有一百条记录插入到
test中,第二次,更新这一百条记录的相应字段,然后再从ha_com上选择没有在
test上的记录再插入
不知那个好一点的
第一天ha_com的内容如下
idno name deptnm statuscd
20901001 张三 财务 DA
20901002 李四 人事 DA
20901003 王五 营业 DA
通过执行存储过程,test的内容也是idno name deptnm statuscd
20901001 张三 财务 DA
20901002 李四 人事 DA
20901003 王五 营业 DA第二天ha_com的内容如下
idno name deptnm statuscd
20901001 张三 财务 GA
20901002 李四 购买 DA
20901003 王五 人事 DA
20909004 孙六 营业 DA
那么通过存储过程,test中的内容应该是
idno name deptnm statuscd
20901001 张三 财务 GA
20901002 李四 购买 DA
20901003 王五 人事 DA
20909004 孙六 营业 DA
呵呵,这么一写,才知道只要每天把test中的内容删除了,然后执行存储过程,把ha_com的内容插入就可以了。
这样的存储得怎么写的,而且怎么设定存储过程在某个指定时间执行的?
create trigger tri_ha on [ha_com] for insert,update,delete
as
delete test from test a,deleted b where a.idno=b.idno
insert into test select * from inserted
go
我已经在服务器1中建立了相关的链接服务器,在服务器1中可以查询视图B的数据。
现在表A的部分数据是从视图B中得到的,表B的数据时刻在变化 ,表A中的表B部分也要时刻变化,
所以要
update 表A where id in (select id from 表B)
并且
insert 表A (select 数据 from 表B where id not in (select id from 表A))
要实现这样的触发器得怎么写的?