Quantcast
Viewing all articles
Browse latest Browse all 3160

SDU Tools: Show a number as text in SQL Server

Years ago, it was common to need to print checks (cheques) from computer systems. Fortunately checks have now pretty much disappeared in most countries. One of the challenges with printing a check, was that you needed to convert an amount of money into words. Even though checks are on the wane, it's still important to do that on some contracts, etc. In our free SDU Tools for developers and DBAs, we added a function NumberAsText to do just that.

You can see how to execute it in the main image above.

We decided not to assume that it's a monetary value, just a number, so you could easily turn it into a monetary value like this:


Image may be NSFW.
Clik here to view.
SDU Tools: Show a number as text in SQL Server

The text is returned in lower-case. It's easy to then use UPPER to force it to upper-case:


Image may be NSFW.
Clik here to view.
SDU Tools: Show a number as text in SQL Server

You could easily add a comma in between the dollars and the cents as well:


Image may be NSFW.
Clik here to view.
SDU Tools: Show a number as text in SQL Server

You can see it in action here:

We hope you find it useful.

To become an SDU Insider and to get our free tools and eBooks, please just visit here:

http://sdutools.sqldownunder.com


Viewing all articles
Browse latest Browse all 3160

Trending Articles