Как преобразовать значение float в значение varchar
I have value contains decimal (15,7) as datatype. It contains 5 digits after decimal point. My value is : 123.107157. When I try to convert the value into "varchar" then in the Output I get 123.107. I want result as 123.10705 after converting the value into varchar.
Что я уже пробовал:
DECLARE @test1 decimal(15,7), @test2 nvarchar(10) SELECT @test1 = 123.1071570
-- Случай 1 :
SELECT cast(@test1 as float) AS value1 -- Ans : 123.107157 -- Value which I got after using cast() SELECT convert(varchar,cast(@test1 as float)) AS value2 -- Ans : 123.107 Value which I got after converting it to varchar
-- Случай 2 :
SELECT convert(DOUBLE PRECISION, @test1) AS value1 -- Ans : 123.107157 -- Value which I got after using DOUBLE SELECT convert(varchar,convert(DOUBLE PRECISION, @test1)) AS value2 -- Ans : 123.107 Value which I got after converting it to varchar