How to convert varchar datatype to float datatype

Naveenmanam
Posted by Naveenmanam under ASP.NET category on | Views : 5777
How to convert varchar datatype to float datatype



In many places we are converting one dataype into different data type.
Here is the example code for converting VARCHAR into FLOAT datatype.
Basically we need to change data types in sqlserver2005
So i am posting simple syntex and example.

SYNTEX


SELECT CONVERT(decimal(15,4),yourvarcharfield)
FROM
TableName


EXAMPLE


DECLARE @Flt VARCHAR(50)
SELECT @Flt = Convert(decimal(15,4),Code) FROM MyTable
PRINT @Flt --I want Flt to be 521698.98999999999

Comments or Responses

Login to post response