Insert into FD_Intras(cIntrID,irate_id,DbDate,nzy,ncq,nyq,ncdell,nde,bde,irate_b_id)
select 无利率,
Select sMax0Id from fd_entities where iBIType=8 ,
2005-06-21,5.6,0,0,0,0,0,
sMax0Id from fd_entities where iBIType=97
其中里边的2个sMax0Id都是从另外一个表中查出来的一个字段值。我想将这2个查出来的字段作为2个值,插入到另一个表中。怎么在一条语句中都写出来??不知道我的描述是否明白?
Insert into FD_Intras(cIntrID,irate_id,DbDate,nzy,ncq,nyq,ncdell,nde,bde,irate_b_id)
select 无利率,A.sMax0Id,2005-06-21,5.6,0,0,0,0,0,B.sMax0Id
from fd_entities A,fd_entities B
where A.iBIType=8 AND B.iBIType=97
Insert into FD_Intras(cIntrID,irate_id,DbDate,nzy,ncq,nyq,ncdell,nde,bde,irate_b_id)
select 无利率,A.sMax0Id,2005-06-21,5.6,0,0,0,0,0,B.sMax0Id
from fd_entities A
left join fd_entities B on A.cIntrID=BcIntrID
where A.iBIType=8 AND B.iBIType=97
楼主的sql嵌套在里面的select返回的结果是一个集合,肯定不行啦,这样试试。
Insert into FD_Intras(cIntrID,irate_id,DbDate,nzy,ncq,nyq,ncdell,nde,bde,irate_b_id)
select 无利率,
Select top 1 sMax0Id from fd_entities where iBIType=8 ,
2005-06-21,5.6,0,0,0,0,0,
sMax0Id from fd_entities where iBIType=97
楼上的说法有点问题;
返回一个集合的话可能会出问题;
但楼主的语法错不在这里;
只要将第二个select语句用括号括起来就可以调试通过:
Insert into FD_Intras(cIntrID,irate_id,DbDate,nzy,ncq,nyq,ncdell,nde,bde,irate_b_id)
select 无利率,
(Select top 1 sMax0Id from fd_entities where iBIType=8 ),
2005-06-21,5.6,0,0,0,0,0,
sMax0Id from fd_entities where iBIType=97