表b初始数据等于表a初始数据,表b数据修改后不一定等于表a的数据.发贴后大家帮忙写了个触发器,(在查询分析器可以执行).可程序运行时当在表一中增加数据时提示如下错误:
实时错误 '-2147217900(80040e14)'
仅当使用了列表,并且IDENTITY_insert 为on时,才能在表'b'中为标识列指定显示值.(使用语言是VB+SQL)
请大家帮看看啊,是什么原因啊,谢谢!!
实时错误 '-2147217900(80040e14)'
仅当使用了列表,并且IDENTITY_insert 为on时,才能在表'b'中为标识列指定显示值.(使用语言是VB+SQL)
请大家帮看看啊,是什么原因啊,谢谢!!
create trigger tri_A
on dbo.a
for insert,update
as if @@rowcount=0 return
if exists(select 1 from a,b where a.id=b.id)
update b set b.设备材料费=a.预设备材料费 from inserted a,b where a.id=b.id
else
insert into b select * from inserted
表结构如下:表A
ID(主键不允许为空,自增值) 预设备材料费
表B
ID(主键不允许为空,自增值) 设备材料费
--> insert into b(...) select ... from inserted...写除了标识列外的所有字段