我有一个Clr用户定义的类型,它接受一个用逗号分隔的值字符串。
转换为此类型时,我失去了一点精确度,我将其缩小到这行代码:
cast(cast(nlinkjt as nvarchar(100)) + ',' +cast(avglrwf as nvarchar(100)) + ',' + cast(avglrwfjt as nvarchar(100)) as dbo.CLRJourneyTime) as clrJT
输出= 29.9376,5.29633e-005,0.00158559
但是原始值是这样的:
nlinkjt = 29.9376097988521 = cast(nlinkjt as nvarchar) = 29.9376
avglrwf = 5.29632961843163E-05 = cast(avglrwf as nvarchar) = 5.29633e-005
avglrwfjt = 0.00158559449482709 = cast(avglrwfjt as nvarchar) = 0.00158559
如何将浮动转换为字符串?
或者是否有另一种声明新的dbo.CLRJourneyTime的方式,就像在.net中一样 像这样:
'new dbo.CLRJourneyTime(nlinkjt , avglrwf , avglrwfjt ) as clrJT'
答案 0 :(得分:1)
好的,刚刚发现浮动列只存储到大约4位小数..所以它可能不重要。