日期:2014-05-17  浏览次数:20603 次

为什么会报错
insert into zs_2013.dbo.td_yxdhdm(YXDH) 
select (select distinct(YXDH)
from T_JHK_ALL where ZSNF='2008' and PCDM='2' and KLDM='1') 
from T_JHK_ALL
我要的是把这个表里YXDH这列的符合条件的部分数据数据插入zs_2013.dbo.td_yxdhdm(YXDH)这一列
但是出现了错误:
消息 512,级别 16,状态 1,第 1 行
子查询返回的值不止一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
语句已终止。

------解决方案--------------------
insert into zs_2013.dbo.td_yxdhdm(YXDH) 
select distinct(YXDH)
 from T_JHK_ALL where ZSNF='2008' and PCDM='2' and KLDM='1'
------解决方案--------------------
try this,

insert into zs_2013.dbo.td_yxdhdm(YXDH) 
 select distinct YXDH
 from T_JHK_ALL 
 where ZSNF='2008' and PCDM='2' and KLDM='1'