i have a query which rounds the value for the particular column name:
select round([CIMtrek_CI_Act],0) as CI FROM [CIMtrek_SystemTable_DatawareHouse]
where [CIMtrek_CI_Act_33] is not null and CIMtrek_CIMtrekUniqueID = 1917
and the reulst is
CI
1
but when i execute the following query :
(SELECT (SELECT [T1].[CIMtrek_CIMtrekUniqueID] AS [CIMtrek_CIMtrekUniqueID]
,round([T1].[CIMtrek_CI_Act],0) AS [CIMtrek_CI_Act]
FROM [CIMtrek_SystemTable_DatawareHouse] T1
WHERE T1.CIMtrek_CIMtrekUniqueID = 1917
FOR XML PATH('Record'), TYPE )) FOR XML PATH('Root')
the result is
<Root>
<Record>
<CIMtrek_CIMtrekUniqueID>1917</CIMtrek_CIMtrekUniqueID>
<CIMtrek_CI_Act>1.000000000000000e+000</CIMtrek_CI_Act>
</Record>
</Root>
the value is not rounded.
if the value is 10.58
than i have to get 11
. Also the field is varchar
if there is no value i have to get empty
string than 0
.
what is the mistake i have done here and how to fix the same
It is rounded. What you see is the XML textual representation of SQL Server's float
.
If you don't like that, cast it to an integer after rounding.
cast(round([T1].[CIMtrek_CI_Act],0) as int)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.