我有这个过程
[...]
BEGIN
SELECT ODMI.VLR_LABOR AS Labor,
O.ID_ODM AS IdODM,
FROM ODM O
JOIN ODM_AREA_IMPACTO ODMI ON ODMI.ID_ODM = O.ID_ODM
JOIN AREA A ON A.ID_AREA = ODMI.ID_AREA
WHERE O.ID_ODM = xx
END
Labor
是c#代码中的小数。
如何在执行程序时将ODMI.VLR_LABOR
转换为deicmal。
我尝试CONVERT(DECIMAL(16,4), height/10.0) AS HeightDecimal
但没有成功。
答案 0 :(得分:1)
您使用变量height
,但它并不存在于您的代码中。试试这个:
BEGIN
SELECT CONVERT(DECIMAL(16,4), CONVERT(DECIMAL(16,4), ODMI.VLR_LABOR)/10.0) AS Labor
O.ID_ODM AS IdODM
FROM ODM O
JOIN ODM_AREA_IMPACTO ODMI ON ODMI.ID_ODM = O.ID_ODM
JOIN AREA A ON A.ID_AREA = ODMI.ID_AREA
WHERE O.ID_ODM = xx
END
答案 1 :(得分:1)
SELECT
CAST(ODMI.VLR_LABOR * 1. / 10 AS DECIMAL(18,4)) AS Labor,
O.ID_ODM AS IdODM
FROM ODM O
JOIN ODM_AREA_IMPACTO ODMI ON ODMI.ID_ODM = O.ID_ODM
JOIN AREA A ON A.ID_AREA = ODMI.ID_AREA
WHERE O.ID_ODM = xx