日期:2014-05-18  浏览次数:20336 次

各位帮忙看一下!(不能从子查询插入!)
我的问题是这样的:找到   ReplyTable   表中   topicid=3的记录(共有四条),将其保存在##b中,删除ReplyTable表中topicid=3的记录,然后从##b中恢复这几条记录,代码如下:

select   *   into   ##b   from   ReplyTable   where   topicid=3
go

select   *   from   ##b
go

delete   from   ReplyTable   where   topicid=3
go

insert   ReplyTable
select   topicID,userID,replyTime,replyContent,signImage,
lastUpdateUser,lastUpdataTime,niceName,userName  
from   ##b
where   topicid=3

执行插入时总是抱错:
服务器:   消息   512,级别   16,状态   1,过程   trig_insertReply,行   5
子查询返回的值多于一个。当子查询跟随在   =、!=、 <、 <=、> 、> =   之后,或子查询用作表达式时,这种情况是不允许的。
语句已终止。

不知道为什么?!



------解决方案--------------------
--这样试试
select * into ##b from ReplyTable where topicid=3
select * from ##b
delete from ReplyTable where topicid=3
insert ReplyTable
select topicID,userID,replyTime,replyContent,signImage,
lastUpdateUser,lastUpdataTime,niceName,userName
from ##b
where topicid=3
go

------解决方案--------------------
ReplyTable表触发器的问题.
trig_insertReply检查这个触发器代码