Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Give the dollar or euro symbol for amount field

Author  Topic 

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-09 : 11:19:33

Hai

I have amount field in my table as decimal. I need a query to display the amount with dollar or euro symbol based on country selection. The country also in same table.

For example If country is US then Amount $1200, If country is UK then Amount €1200.

Thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-09 : 11:33:41
I think it will be better for you to do this it at front end. Most front end applications have currency formatting functions which provides you with result in desired currency. What is front end you are using?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-09 : 11:35:45
doesn't UK stil use pounds and not euros?
but yes this should be done in the front end like visakh16 said

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-09 : 12:35:46
Thanks. I am using vb.net, and I get the result and bind in a grid. So from front end it is some difficulties.

kamal.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-09 : 12:41:33
No. Use the FORMAT property for the GRID and you're set.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-09 : 13:07:36
I'm using asp.net gridview. How can I use FORMAT property, kindly help me.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-09 : 13:12:53
Use FormatCurrency() function

http://msconline.maconstate.edu/tutorials/VBNET/VBNET01/vbnet01-08.aspx
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-09 : 14:53:57
Thanks. above link is very useful.

But I written the stored procedure to add the $ or € symbol by using CASE functionality in SQL server.
So how to merge the symbol to the amount field.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-09 : 15:19:09
for the last time kamal:
DO this in the front end!

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2008-04-09 : 15:41:51
Ok Thanks. I will do it from front end.
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-04-09 : 16:30:27
And the reason why, Kamal, is that the only way to prepend the currency symbol to the value is by converting the value to a string. And once you do that, it may look pretty but it can no longer be added, subtracted, averaged, or used in any mathematical calculation. So the database should supply actual values and then let the front end format them or manipulate them however it wants.

e4 d5 xd5 Nf6
Go to Top of Page
   

- Advertisement -