一个触发器问题
我想插入一个表A的同时给另一个表B的相似编号的某一字段数据插入同样值(colorlight)
例如:表A
id factoryid clothid colorlight
1 123 12-12 A
2 123 12-13 B
表B
id factoryid clothid colorlight
1 123 12-12-1 A
2 123 12-12-2 A
3 123 12-12-3 A
4 123 12-13-1 B
5 123 12-13-2 B
问题点数:50、回复次数:3Top
1 楼friendliu(无为)回复于 2005-03-29 08:54:39 得分 25
create trigger test on 表A
for inserted
begin
insert into 表B select * from inserted
end
goTop
2 楼geniusqing(依帆)回复于 2005-03-29 08:58:56 得分 0
开始时表B中colorlight字段是空的,Top
3 楼xluzhong(Ralph)回复于 2005-03-29 09:39:23 得分 25
create trigger test on 表A
for inserted
begin
update 表B
set colorlight=b.colorlight
from 表B a
inner join inserted b
on a.factoryid=b.factoryid
and left(a.clothid,5)=b.clothid
end
go
Top




