我遇到的问题是我在存储过程中创建了一个#TmpTbl,它将值插入到具有REAL数据类型的字段中。当我将此值写入另一个数据类型为NVARCHAR(200)的表时,它会更改原始值。
REAL数据类型值= 2122222转换后的NVARCHAR数据类型值= 2122220
答案 0 :(得分:0)
使用STR
https://msdn.microsoft.com/en-us/library/ms189527.aspx
create table t (i int,x nvarchar(200))
declare @x real = 2122222
insert into t (i,x) select 1,@x
insert into t (i,x) select 2,str (@x)
select * from t order by i
+---+--------------+
| i | x |
+---+--------------+
| 1 | 2.12222e+006 |
+---+--------------+
| 2 | 2122222 |
+---+--------------+