我有一个 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'