update [dbo].[ICStockBill]
set [FHeadSelfB0436]=
(
--此子查询可能会出现多条数据,目前测试的是一条数据,后面多条数据话要拼接后保存
select distinct ICStockBillEntry.FInterID,
ICMO.FInterID,
Convert(decimal(18,2),ICMO.FQty),
SEOrder.FBillNo,
t_ICItem.FName,t_ICItem.FShortNumber
from [AIS20160601].[dbo].t_ICItem,[AIS20160601].[dbo].ICStockBillEntry,[AIS20160601].[dbo].ICMO,[AIS20160601].[dbo].SEOrder
where ICStockBillEntry.FSourceInterId=ICMO.FInterID
and ICMO.FItemID=t_ICItem.FItemID
and ICMO.FOrderInterID=SEOrder.FInterID
)
FROM [dbo].[ICStockBill] a,[dbo].[ICStockBillEntry] b
--下面判断是否当次添加ID,单据类型是否为‘24’,根据当次ID查找明细表中存在多条[FInterID]项然后判断是否都为 ‘85’
where a.[FInterID]=(select [FInterID] from inserted)
and
(select a.[FTranType] where a.[FInterID]=(select [FInterID] from inserted))='24'
and
(select b.[FSourceTranType] where b.[FInterID]=(select [FInterID] from inserted))='85'
SQL 2008
报下面错误
消息 116,级别 16,状态 1,过程 ICStockBill_RWHQ,第 27 行
当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式
比如查询某个表中相同ID中登记时间最大的记录:
select * from bb t where exists (selec * form bb where id=t.id and 登记时间<t.登记时间)
如果不用exists ,可以如下方式写:
select a.* from bb a,(select id,max(登记时间) as 登记时间 from bb group by id) b
where a.id=b.id and a.登记时间=b.登记时间