8

I want to use unicode text in my site. I have nvarchar(max) data type in database to store the data. When I save unicode text into database, it works fine. However when i try to perform some sql operation the unicode text is changed to "?????" Eg, the query below

declare @unicodetext nvarchar(250)
set @unicodetext='बन्द'
select @unicodetext

results

sqlunicode

What is the solution for this? Thanks

2
  • What is the default collation of the database? Commented May 10, 2012 at 8:38
  • @Oded The default collation is SQL_Latin1_General_CP1_CI_AS Commented May 10, 2012 at 8:40

2 Answers 2

12

Try

declare @unicodetext nvarchar(250)
set @unicodetext = N'बन्द'
select @unicodetext

Maybe you noticed that SQL Server uses N to any quoted string input when generating DDL scripts for you.

Sign up to request clarification or add additional context in comments.

1 Comment

Good spot. Unicode text needs to be qualifies as such using the N modifier.
2

you have to set your database collation to a collation that accepts this type of character or you can add the collation clause on your select like this (google told me this is a Hindi character)

declare @unicodetext nvarchar(250)
set @unicodetext='बन्द'
select @unicodetext
COLLATE Indic_General_90_CI_AS 

that wont work, but I found this on BOL for SQL Server 2005:

4 The Hindi collation is deprecated in SQL Server 2005 because the Windows 2000 sorting table is used in this SQL Server release. The collation still exists in the server, but it will not be supported in a future SQL Server release, and it does not show up in ::fn_helpcollations().

5 The Hindi and Lithuanian_Classic collations are deprecated in SQL Server 2005. These collations still exist in the server, but they will not be supported in a future SQL Server release, and they do not show up in ::fn_helpcollations().

for 2008:

Hindi (India) - Not available at server level

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.