SQL2000运行语句出错求帮忙
SQL2000运行语句出错求帮忙
declare @i int
set @i = 1 ---一阶
declare @t table(id varchar (64), BillId int , MGoodsId int,
MQty decimal(18,5), BomVer char(32), ItemNo int ,
GoodsId int, Qty decimal(18,5), BomId char(32),
BomIdName char(32), Price decimal(18,5), AM decimal(18,5),
LevelId int , PPRICE decimal(18,5) , CAMT decimal(18,5)
, DD1 VARCHAR(64) , DD3 VARCHAR(64) )
---Bomid=子件BOMID?bomidname=子件版本名称?
insert @t
select a.BillId, a.BillId, a.GoodsId,
a.Qty, a.BomVer, b.ItemNo,
b.GoodsId, b.Qty, b.BomId,
c.BOMVER AS BomIdName, d.Price, b.Qty*d.Price AS AM,
@i , D.PPRICE , B.QTY*D.PPRICE AS CAMT , B.DD1 , B.DD3
from vip_M_BOMV1 a ----主
join vip_M_BOMV2 b ON a.BillId = b.BillId ---从
left join vip_M_BOMV1 c ON b.BomId = c.bomver --------改为
join vip_R_GOODSPRICE() d ON b.GoodsId = d.GoodsId
while @i <= 10 AND @@RowCount <> 0
begin
set @i = @i + 1
insert @t
select a.ID+','+cast(b.billid as varchar(32)), b.BillId, a.BomIdName,
a.Qty, a.BomIdName, b.ItemNo,
b.GoodsId, b.Qty, b.BomId,
c.BOMVER AS BomIdName, d.Price, b.Qty*d.Price AS AM,
@i , D.PPRICE , B.QTY*D.PPRICE AS CAMT , B.DD1 , B.DD3
from @t a
join vip_M_BOMV2 b ON a.BomId = b.BillId
left join vip_M_BOMV1 c ON b.BomId = c.bomver ------改为
join vip_R_GOODSPRICE() d ON b.GoodsId = d.GoodsId
----------- where a.BomIdName IS NOT NULL AND a.LevelId = @i-1
where a.BomIdName<>'' AND a.LevelId = @i-1
end
运行有如果错误提示,请问是哪里问题?SQL2000环境
(所影响的行数为 105 行)
服务器: 消息 245,级别 16,状态 1,行 27
将 varchar 值 'B ' 转换为数据类型为 int 的列时发生语法错误。
[解决办法]
a.BomId = b.BillId
改为 a.BomId = b.BomId