我现在有两个表
Ax表
字段 Feild1 类型 int 字段Feild2 类型 textAx_Bak表
字段 Feild1 类型 int 字段Feild2 类型 text 字段Feild3类型 int我在Ax创建触发器如下:Create Trigger Ax_Trigger
On Ax
for insert,update,delete
as
begin
Declare @Inserted int,@Deleted int
Set @Inserted  = 0
Set @Deleted = 0
Select @Inserted  = count(*) from Inserted
Select @Deleted = count(*) from Deleted
if @Inserted > 0 and @Deleted = 0
   insert into Ax_BAK select *,1 from inserted
if @Inserted > 0 and @Deleted > 0
   insert into Ax_BAK select *,2 from Deleted
if @Inserted > 0 and @Deleted > 0
   insert into Ax_BAK select *,1 from inserted
if @Inserted = 0 and @Deleted > 0
   insert into Ax_BAK select *,2 from Deleted
end;目前遇到的问题如下,当字段Feild2 类型是text或者ntext时,发生错误,如果是varchar 就没有问题?

解决方案 »

  1.   

    消息 311,级别 16,状态 1,过程 Ax_Trigger,第 12 行
    不能在 'inserted' 表和 'deleted' 表中使用 text、ntext 或 image 列。
    消息 213,级别 16,状态 1,过程 Ax_Trigger,第 12 行
    插入错误: 列名或所提供值的数目与表定义不匹配。
      

  2.   

    查到网上说把 for 换成 instead of 不行啊instead of 是认识了text等字段但是内容就不插入原表了,这样失去了对原表的操作。
      

  3.   

    微软text、ntext 或 image 已经不推荐使用了。