Solved

SQL Server Comparing Cyrillic Characters with Latin ones

Posted on 2007-11-19
4
1,824 Views
Last Modified: 2008-02-01
Hi,

I have a table (AlphabetTable) with the following columns:
RussianCharacter, GermanCharacter

I want to query like this:

select GermanCharacter from AlphabetTable where RussianCharacter = 'и'

My SQL Server has the following collation: Latin1_General_CI_AS

My query always returns no rows even though all the Russian characters are entered into the table. This is for a very basic function that translates a customer name entered in Cyrillic.

Assistance would be greatly appreciated.

Thanks

0
Comment
Question by:milesryoung
  • 2
4 Comments
 
LVL 35

Expert Comment

by:David Todd
ID: 20316726
Hi,

The collations of the two expressions being compared needs to be the same.

What are your collation settings?

The collate keyword can be used to cast the collation of a string in a comparision.

Neither the SQL 2000 or the SQL 2005 BOL had good examples - COLLATE (Transact-SQL) was the best imo.

HTH
  David
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20318607
what the the column types for GermanCharacter and RussianCharacter, nvarchar?
if it is, then use
select GermanCharacter from AlphabetTable where RussianCharacter = N'russiantext'

you can also try
select GermanCharacter from AlphabetTable where RussianCharacter = 'russiantext' collate database_default
(or the N'russiantext') version
0
 

Author Comment

by:milesryoung
ID: 20318806
Hi, thanks for the help.

Both columns are type nvarchar(4) and your first solution works fine when I type in the query in query window with a russian character within single quotes. I.E. N'x'

That is a solution to my original question so I'll accept it as the solution but if I pass a character from a stored procedure to a function, how can I make use of that "N"? I.E. N'@myCharacter'



0
 
LVL 25

Expert Comment

by:imitchie
ID: 20318942
as long as you pass them around as nvarchar, you should be fine. i.e.

declare @param nvarchar(10) set @param = N'somerussian'
exec myproc @param      <--- passing as nvarchar

create proc myproc ( @myvalue nvarchar(10)  ....   << receiving as nvarchar
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now