将字符串45*120*100截取转化为数值计算
SELECT T0.[DocNum],T0.[OriginNum], T0.[CardCode],t2.cardname, T0.[PostDate], T0.[ItemCode],t1.itemname,
T0.[PlannedQty], T0.[CmpltQty],t1.spec,t1.ValidComm,(T0.[CmpltQty]*t1.ValidComm) FROM OWOR T0
inner join oitm t1 on t1.itemcode = t0.itemcode left join ocrd t2 on t0.cardcode=t2.cardcode
where T0.[Status] <> 'C'
其中 t1.spec 是存类似45*120*100的字符串数值,现在要将其取出来做计算 求解
------解决思路----------------------
有N种方法
如果格式都像 45*120*100 这样的话
可以
select cast(parsename(replace(t1.spec,'*','.'),3) as int)* cast(parsename(replace(t1.spec,'*','.'),2) as int)* cast(parsename(replace(t1.spec,'*','.'),1) as int)
------解决思路----------------------
EXEC('select 45*120*100')