Click here to Skip to main content
15,867,771 members
Articles / Database Development / SQL Server / SQL Server 2008

Arabic currency conversion from numbers to letters

Rate me:
Please Sign up or sign in to vote.
4.79/5 (9 votes)
9 Aug 2009CPOL1 min read 41.5K   3K   14   8
Convert numbers to characters for Arabic applications.

example.jpg

Introduction

This project can be useful in many applications, like ERPs, financial applications, or any application used by Arabic speakers to display any number "as digits to characters", which is called - in some Arab countries - "tafqit".

Background

It's known that to write a number in Arabic characters, it's a little bit hard, as a number like 123 is written in English as "One Hundred twenty three", but in Arabic, it will be "One Hundred and three and twenty". So, for a big number - say 7 digits - it will be a little bit confusing to write it in this complicated form.

Using the code

The advantage of this code that it's pure SQL , so it will be easy to add it to any function, Stored Procedure, or View. Also, it can be used in both web and Windows applications. To use the code, first run the attached script in the desired database and then use the function called currency_conversion like this:

SQL
SELECT dbo.currency_conversion(12.10)

In the last example, the output will be:

currency
------------------------------------------
اثني عشر جنيها  و عشره قرشا 

(1 row(s) affected)

Points of interest

As I mentioned before, this function can be used in both Windows and web applications as it is just a SQL function. Also, as it's a scalar function, it can be used in both Views and Stored Procedures. You can also modify the script to fit your country's currency; just replace "Egyptian Pound" with your currency.

History

  • 08/08/2009 --> Initial version.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Alarm.com
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionsome numbers are not working ok Pin
almounkez9-Jan-20 10:05
almounkez9-Jan-20 10:05 
QuestionCrystal report Pin
Member 1412671922-Jan-19 18:52
Member 1412671922-Jan-19 18:52 
PraiseNice and informative Pin
javedcodeproject8-Jul-18 3:19
javedcodeproject8-Jul-18 3:19 
QuestionArabic currency conversion from numbers to letters Pin
Member 1165132918-May-15 0:53
Member 1165132918-May-15 0:53 
AnswerRe: Arabic currency conversion from numbers to letters Pin
Wael R. Mansour18-Jan-17 17:57
Wael R. Mansour18-Jan-17 17:57 
GeneralRe: Arabic currency conversion from numbers to letters Pin
Zapss12-Mar-19 19:30
Zapss12-Mar-19 19:30 
hi,
In script table currencies already collate arabic even thou output same as above thread [??????????].

CREATE TABLE [dbo].[currencies](
	[id] [uniqueidentifier] NOT NULL,
	[number] [int] NOT NULL,
	[number_string] [nvarchar](max) COLLATE Arabic_CI_AS NOT NULL,

GeneralExcellent! Pin
Omar Gameel Salem24-Apr-10 23:21
professionalOmar Gameel Salem24-Apr-10 23:21 
GeneralRe: Excellent! Pin
Member 1254389224-Jan-18 1:50
Member 1254389224-Jan-18 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.