• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

Comparing Unicode strings in SQL Server


Does anyone know how to compare two columns in SQL Server table that contain Unicode characters.

For eg: When I run this query it works :
select * from ACC_Contact
Title = N'¿¿¿¿'

But when I am trying to query same table by joining two tables based on columns containing unicode characters, the search fails.

This query does not work:
FROM vw_contacts src_cont
      JOIN JOIN ACC_Contact stage_cont (NOLOCK) ON LEFT(LTRIM(RTRIM(ISNULL(src_cont.Title, ''))), 50) = stage_cont.Title
            AND ISNULL(src_cont.First_Name, '')            = stage_cont.FirstName
            AND ISNULL(src_cont.Last_Name, '')            = stage_cont.LastName

Can you pls tell me how to append N in front of column name, just the way we can do in the first query I mentioned.

Thanks in advance for helping.
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the N'<...>  is the same as CAST('<...>' as nvarchar)
in other words: CAST( yourfield as nvarchar ) should do the job.
AmitJain001Author Commented:
Thanks it works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now