数学公式不能计算??
单价是decimal类型,需要通过公式计算出来,现在显示的是字符串,公式不计算,我希望得到计算出来的decimal类型。
--sql语句如下:
SELECT T.QuoteDetId,
T.QuoteID,
T.QuoteNO,
T.MaterialID,
T.MaterialNO,
T.BatchID,
T.IsBatch,
replace(replace( replace(replace(T6.Formula,'单价',T.UnitPrice),'length',T5.length),'Width',T5.Width),'Weight',T5.Weight) as '单价',
T.Currency,
T.ExchangeRate,
T.ActPeriodDay,
T.Remark,
T.InquireID,
T.InquireNO,
T.InqDetID,
T.SelectFlag,
T2.IsBySupplier,
T3.BussinessId,
T3.ApproveStatus,
T3.CreateByID,
T3.ApproveEndDt
FROM dbo.MPS_QuoteDetail AS T
INNER JOIN dbo.MPS_Quote AS T2 ON T.QuoteID = T2.QuoteID and T.IsBatch=1
INNER JOIN dbo.MPS_Inquire AS T3 ON T3.InquireID = T.InquireID
INNER JOIN dbo.MPS_InquireDetail AS T4 ON T4.InquireID = T3.InquireID
AND T.InqDetID=T4.InqDetID
AND T2.ApproveStatus = 1
AND T.UnitPrice>0
INNER JOIN dbo.MPS_Material T5 on T.BatchID=T4.BatchID
and T4.Brand=T5.Brand
and T5.Weight between T4.WeightMin and T4.WeightMax
and T5.IsParticular=T4.IsParticular
inner join MPS_BatchSet T6 on T5.BatchID=T6.BatchID
运行结果,其中一列,显示如下:
7470.0000*1194.000*889.000*190/2000000000,
------解决方案--------------------你计算的时候直接运算就行了,没看懂为啥你用那么多replace函数
------解决方案--------------------/*--计算给定算术表达式(公式)的值
计算给定算术表达式的值
此方法由VB版hhjjhjhj(大头)
提供的VB处理程序程序上改造而来
--邹建2004.07(引用请注明此信息)--*/
/*--调用示例
select dbo.f_calc('123+456')
--*/
ALTER function f_calc(
@str varchar(1000) --要计算的表达式
)returns sql_variant
as
begin
declare @re sql_variant
declare @err int,@src varchar(255),@desc varchar(255)
declare @ob