March 5, 2012 at 8:39 am
I want to store currency symbols in a table. I checked the official unicode page[/url] for the unicode character codes for currency symbols. For example, the Euro symbol code is 20AC. I can't seem to find how to enter this in SQL Server so it will store the symbol.
If I try SELECT UNICODE('€')
it returns 8364, not 20AC.
I can use SELECT NCHAR(8364)
and it returns the Euro symbol just fine, but SELECT NCHAR('20AC')
doesn't work.
Is there a command that uses the official Unicode character codes? Failing that, is there a site that lists the SQL Server all numeric codes for all Unicode characters?
--------------------------------------
When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
--------------------------------------
It’s unpleasantly like being drunk.
What’s so unpleasant about being drunk?
You ask a glass of water. -- Douglas Adams
March 5, 2012 at 8:51 am
Stefan Krzywicki (3/5/2012)
I want to store currency symbols in a table. I checked the official unicode page[/url] for the unicode character codes for currency symbols. For example, the Euro symbol code is 20AC. I can't seem to find how to enter this in SQL Server so it will store the symbol.If I try
SELECT UNICODE('€')
it returns 8364, not 20AC.I can use
SELECT NCHAR(8364)
and it returns the Euro symbol just fine, butSELECT NCHAR('20AC')
doesn't work.Is there a command that uses the official Unicode character codes? Failing that, is there a site that lists the SQL Server all numeric codes for all Unicode characters?
If you check the following:
http://msdn.microsoft.com/en-us/library/ms182673.aspx
you can find that NCHAR() function expects the "integer_expression" not a HEX.
What you can do in SQLServer 2008 is:
1. Use varchar representation of HEX unicode
2. Convert to varbinary(8) (check the third param used in CONVERT...)
3. Conevrt to int
4. Get NCHAR:
select NCHAR(CONVERT(INT, CONVERT(VARBINARY(8),'0x20AC', 1)))
March 5, 2012 at 9:01 am
Eugene Elutin (3/5/2012)
Stefan Krzywicki (3/5/2012)
I want to store currency symbols in a table. I checked the official unicode page[/url] for the unicode character codes for currency symbols. For example, the Euro symbol code is 20AC. I can't seem to find how to enter this in SQL Server so it will store the symbol.If I try
SELECT UNICODE('€')
it returns 8364, not 20AC.I can use
SELECT NCHAR(8364)
and it returns the Euro symbol just fine, butSELECT NCHAR('20AC')
doesn't work.Is there a command that uses the official Unicode character codes? Failing that, is there a site that lists the SQL Server all numeric codes for all Unicode characters?
If you check the following:
http://msdn.microsoft.com/en-us/library/ms182673.aspx
you can find that NCHAR() function expects the "integer_expression" not a HEX.
What you can do in SQLServer 2008 is:
1. Use varchar representation of HEX unicode
2. Convert to varbinary(8) (check the third param used in CONVERT...)
3. Conevrt to int
4. Get NCHAR:
select NCHAR(CONVERT(INT, CONVERT(VARBINARY(8),'0x20AC', 1)))
Awesome, thanks! I knew it was expecting an int, not a HEX. I included the line about that not working to better illustrate how I wanted it to work.
I'll give this a shot.
--------------------------------------
When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
--------------------------------------
It’s unpleasantly like being drunk.
What’s so unpleasant about being drunk?
You ask a glass of water. -- Douglas Adams
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply