Solved

SQL Server Comparing Cyrillic Characters with Latin ones

Posted on 2007-11-19
4
1,834 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

22 Experts available now in Live!

Get 1:1 Help Now