Solved

SQL Server Comparing Cyrillic Characters with Latin ones

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql Data via Excel--performance issues 2 56
How to run sql statements from SQLCMD or command line 2 66
convert null in sql server 12 46
Loops and updating in SQL Query 9 54
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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