Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Convert a number to words

By Don Frazier,

This is a handy function that converts a  number (integer) into its word format.  This might be handy if you need to print a check formatted number in words.  Currently it supports an integer but it would be almost nothing to convert to support a bigint or decimal.

The components are
1) a table named PlaceValue that holds certain number parts and place values
2) A function named FormatTriplet() that formats a 3-digit grouping
3) The actual function named NumberToText() that formats a number.

this is rather slow because long numbers (millions) may take up to 9 hits to the data base.  If you're doing lots of these, i recommend creating a view (preferably indexed) with this value as one of the columns.  Or create a denormalized field and store this value in it.

Total article views: 201 | Views in the last 30 days: 1
Related Articles

Format Phone Number function

Function to format phone numbers entered as text.


format the number in indian currency format

format the number in indian currency format


Convert integers/numbers into binary format - viceversa

This functions are used to convert integers/numbers into binary format and viceversa.


Formating number

Formating number


Function to format a number

My number formatting function doesn't work as expected


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones