SQL SERVER – Display Rupee Symbol in SSMS

Recently, I was reached out by one of the my financial technology clients based out of the USA who has just launched their services in India. Their system worked fine in most of the area but the challenge was to display the Indian currency sign. They really did not want to do custom code their system or change collation or anything. Just instead of US Dollar Sign ($), they wanted to display it with Indian Rupee Sign (₹). Let us learn today how we can Display Rupee Symbol in SSMS.

SQL SERVER - Display Rupee Symbol in SSMS Rupee-800x510

If your system is set up to use datatype money or decimal or int, you can use the language encoding to display dollar or rupee Sign next to it. Here is a very simple example of it.

DECLARE @currency money = 1234.56;
SELECT @currency NoFilter,
FORMAT(@currency, 'C', 'en-us') 'en-us',
FORMAT(@currency, 'C', 'en-in') 'en-in',
FORMAT(@currency, 'C', 'hi-in') 'hi-in';

In the above format function, we have the first parameter the value, the second parameter is the format and the third parameter is culture.

FORMAT ( value, format [, culture ] )

When you run the above code, you will get the following results.

You may notice in the resultset there is a very subtle difference in the resultsets. While we are looking at the result as en-in there is a small gap between rupee sign and amount whereas when hi-in is used there is no difference space between the rupee sign and amount. This is because how each of the culture info is encoded.

Here is an example of a couple of other Indian languages as well, where you can also show the Rupee sign.

DECLARE @currency money = 1234.56;
SELECT @currency NoFilter,
FORMAT(@currency, 'C', 'hi-in') 'hi-in',
FORMAT(@currency, 'C', 'gu-in') 'gu-in',
FORMAT(@currency, 'C', 'kn-in') 'kn-in';

Here is the result of the query ran above.

As the sign of rupee is the same in all the languages, you do not see any difference in the result. However, the result may differ when there is a different string besides rupee sign for example dates.

DECLARE @currency datetime = GETDATE();
FORMAT(@currency, 'D', 'en-us') 'en-us',
FORMAT(@currency, 'D', 'hi-in') 'hi-in',
FORMAT(@currency, 'D', 'gu-in') 'gu-in',
FORMAT(@currency, 'D', 'kn-in') 'kn-in';

When you run the above statement, you get the following results.

As a result, now you can see how each of the cultures makes different to display results.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL Function, SQL Scripts, SQL Server, SQL Server Management Studio, SSMS
Previous Post
SQL SERVER – Script to Find All Columns with a Specific Name in Database
Next Post
SQL SERVER – Query to List All Jobs with Owners

Related Posts

3 Comments. Leave new

  • Mikhail Zemelshteyn
    January 28, 2020 2:48 am

    Is there a reason you are declaring ‘currancy’ and not ‘currency’?
    Just curious on the spelling

    • Just an incorrect auto-correct filter did that. I just fixed it.

      Thanks for bringing to my attention my friend.

    March 6, 2020 1:20 pm

    I learnt something new and interesting today.

    Thanks for making my day.


Leave a ReplyCancel reply

Exit mobile version