Float datatype in Sql Server

Float data type will give you approximate result while converting into another data type as shown in the below example


declare @test float
select @test = 50225.48
select @test
select cast((@test) as varchar(12))


output: 50225.48 -> Actually value
50225.5 –> After conversion

Whereas in decimal data type whatever values is present that will get converted as it into another data type. Below is example of the same.


declare @decimal decimal(7,2)
set @decimal = 50225.48
select @decimal
select cast((@decimal) as varchar(12))


output: 50225.48 – Value in decimal variable
50225.48 – No change after conversion


Leave a Reply




+ 4 = 5