Converting VARCHAR to FLOAT in SQL Server 2005

How to Convert from VARCHAR into FLOAT in Sql Server 2005?

In many places we are converting one dataype into different data type.
Here is the example code for converting VARCHAR into FLOAT datatype.

SELECT
CONVERT(decimal(17,7),varcharField)
FROM
sampleTable



DECLARE @Y VARCHAR(20)
SELECT @Y = convert(decimal(17,11),Code) FROM TestTable
PRINT @Y --I want Y to be 521698.98999999999


Enjoy SQL Coding...

No comments: