How to Convert Float to String in T-SQL

Written by brendan mason
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Convert Float to String in T-SQL
Formatting numbers for reporting can necessitate converting them to a string format. (Jupiterimages/ Images)

Floating point numbers are represented by the float data type in SQL Server. Operations, such as string concatenation, require converting a floating point number to a string to avoid data type conversion errors. This can quite easily be achieved through the use of the T-SQL "CAST()" function.

Skill level:

Other People Are Reading


  1. 1

    Open SQL Server Management Studio.

  2. 2

    Open a new query window.

  3. 3

    Convert a floating-point number to a string using the CAST() function by executing the following query statement. Replace "<float>" with any floating point number and "<length>" with the total number of digits in the number plus the decimal point:

    SELECT CAST(<float> AS CHAR(<length>))

Tips and warnings

  • The "CONVERT()" function can be substituted for "CAST()", if preferred. The number can be converted to a VARCHAR instead of a CHAR, if preferred.
  • Casting a floating point number to a CHAR of fewer characters than the number of digits and decimal in the number will result in an arithmetic overflow error.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.