I am doing this
declare @num float = 7708369000
select @num as [float],
convert(varchar, @num) as [varchar]
it gives me this
float varchar
---------------------- ------------------------------
7708369000 7.70837e+009
But I want this
float varchar
---------------------- ------------------------------
7708369000 7708369000
Please help.
If you are planning to convert varchar to float you should know that these two data types are not compatible with each other.
Convert Float to Int In this example, we will convert a float data type to integer. In the following query, we will declare a variable that data type is float and then we will use the SQL CONVERT function in order to convert float value to integer so for that we will perform data converting operation.
CAST Function to convert int to string In this example, we are converting the OrderQty which is an integer into varchar with SELECT CAST syntax.
convert it to decimal first,
CAST(CAST(@num AS DECIMAL(20)) AS VARCHAR(20))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With