SQL Clone
SQLServerCentral is supported by Redgate
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)

Converting money to the word value.

By James Travis,

With this script you can supply an money value such as $12525.83 and it will return the word value "Twelve Thousand Five Hundred And Twenty-Five Dollars And Eighty-Three Cents".
It is comprised of a table for Number to Name and a procedure to parse into it's pieces
NOTE: This only goes to billions at this point, but easy enough to expand.
May work even better as a function in 2000.

Update Notice: If you tried this code before April 17, 2002 the following bug fixes have been made.

.00 throwing error has been fixed.
20.00 displaying "Twenty-Dollars" now corrrectly diplays "Twenty Dollars".
111111.25 Not showing values for Thousands, Millions, Billions with a 1 in the Tens place corrected.
Corrected single ones position for each place all doing single digits amount for place as double that same number, for example 2000 was outputting Twenty-Two Thousand.
Got rid of second "and" in output when there is cents so instead of 250.12 being "Two Hundred And Fifty Dollars And Twelve Cents" now outputs "Two Hundred Fifty Dollars And Twelve Cents" unless is 250 then is "Two Hundred And Fifty Dollars".

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

$123 --> One Hundred Twenty-three ...

Does anyone have any script or know a way that I can convert $amount to words, as written on a check...


fnArabToEnglish(from Arabian number to english)

This function can convert a Arabian number to english,for example,if you input 1234.56, then you'll ...


Book Review: The Billion Dollar Game

The Billion Dollar Game: Behind the Scenes of the Greatest Day In American Sport – Super Bowl Sunday...


Historical Dollars

Comments posted to this topic are about the item [B]Historical Dollars[/B] I wouldn't put a salary h...


Off topic: The two cycle engine and your career path

I’ve been in technology for twenty years now. I’ve seen hundreds of environments, nearly 300 while e...