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)
 Multiple currency in one Collum

Author  Topic 

MacJK
Starting Member

24 Posts

Posted - 2009-12-16 : 17:29:24
Hello, I need to show multiple currency in one Colum (ShowPrice) how I can format each correct?

PK Name Price(money) Currency ShowPrice
1 ABC 1500,0000 EUR €1.500,00
2 CFE 2400,0000 USD $1,500.00
3 CVF 200,0000 USD $200.00
4 XDE 800,0000 EUR €800,00

is there a function or convert style i can use in the SELECT?

for USD i use this but what for other currencys?

, '$'+CONVERT(VARCHAR, '200',1) AS ShowPrice

Many thanks for help and hints!

br
Jaroslaw

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-12-16 : 18:10:29
There is no function in SQL for that. You could do something like

CASE Currency
WHEN 'EUR' THEN '€'
WHEN 'USD' THEN '$'
END + convert(varchar(10),showprice)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-16 : 18:49:05
But in a few hours Madhivanan is gonna reply that you should be doing these kind of formatting in your front end
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-12-16 : 20:59:03
I may be wrong but I don't think front end will be able to do that.

create a table to store the currency code and the corresponding currency sign. Or if you have a currency table, add the sign column to it.

inner join to the currency table and return the sign as a column and let the front end perform the required formatting. Concatenate it in SQL will means you are returning the ShowPrice to your application as a string and you will not be able to perform any sorting with that






KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-17 : 02:16:21
quote:
Originally posted by vijayisonly

But in a few hours Madhivanan is gonna reply that you should be doing these kind of formatting in your front end


Yes it is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -