触发器的问题,急用!

whidon 2003-08-14 05:30:08
高手们,一个大问题:SQL Server 2000 中,对表使用触发器,如果表中存在text、ntext、image字段,则没法使用inserted、deleted表,我查过资料兼容级别为65时,上述问题不存在,可是设定数据库的兼容级别为65后连一个简单的SQL语句,都没法执行了,如delete from 表 where id = 123
各位仁兄,有没有好的方法?小弟急用,拜托了!!!?????
...全文
51 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-08-16
  • 打赏
  • 举报
回复
create table temp (id int,name text)
go
create table temp1 (id int,name text)

go
create trigger t_name on temp
INSTEAD OF insert
as
insert temp select * from inserted
insert temp1 select * from inserted

go
insert into temp values (1,'asf')

select * from temp1

drop table temp,temp1
whidon 2003-08-16
  • 打赏
  • 举报
回复
to nboys: 我的意思是... 例如你给的例子,insert into temp values (1,'asf'), 实际上数据并没有插入到 temp表中
nboys 2003-08-15
  • 打赏
  • 举报
回复
可以执行吧:

试一试这个:
create table temp (id int,name text)
go
create table temp1 (id int,name text)

go
create trigger t_name on temp
INSTEAD OF insert
as
insert into temp1 select * from inserted

go
insert into temp values (1,'asf')

select * from temp1

drop table temp,temp1
whidon 2003-08-15
  • 打赏
  • 举报
回复
to: caiyunxia 如果用INSTEAD OF触发器,则SQL语句将不再执行,这个问题如何解决?
caiyunxia 2003-08-14
  • 打赏
  • 举报
回复
可以用INSTEAD OF触发器
whidon 2003-08-14
  • 打赏
  • 举报
回复
可能我没有说的太清楚,我的意思是在SQL Server 2000中,如果你的表中存在text、ntext、image字段,而你写的触发器又用到了inserted、deleted表,则 create trigger出错
服务器: 消息 311,级别 16,状态 1,过程 InsEmployeeData,行 32
不能在 'inserted' 表和 'deleted' 表中使用 text、ntext 或 image 列。
这个问题如何解决?
txlicenhe 2003-08-14
  • 打赏
  • 举报
回复
在触发器中不对text、ntext、image类型的字段操作
在inserted,deleted表中也不查这些字段.
nboys 2003-08-14
  • 打赏
  • 举报
回复
在触发器不对text、ntext、image类型的字段操作

34,875

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧