3

I have a table UserType:

 id (int),
 type nvarchar(50)

I have inserted some rows into that table

 INSERT INTO [UserType] VALUES (N'កក្កដា');
 INSERT INTO [UserType] VALUES (N'វិច្ឆិកា');

And it's successfully inserted.

Then when I tried to query it back

select * 
from [UserType] 
where type=N'កក្កដា';

It returns all rows.

What's wrong? Please help!

4
  • are you serious what does the * in your query mean.. you are telling it to select * from [UserType] where type=N'កក្កដា'; perhaps you should alter your query to only return UserType also do a google search on how to return Unicode String from Sql Server I would also recommend reading up on what SELECT * means here is a start for you msdn.microsoft.com/en-us/library/ms180059.aspx Commented Jan 27, 2015 at 16:24
  • Whats your database collation Commented Jan 27, 2015 at 16:26
  • I have edited your title. Please see, "Should questions include “tags” in their titles?", where the consensus is "no, they should not". Commented Jan 27, 2015 at 16:29
  • My database collation is "SQL_Latin1_General_CP1_CI_AS" Commented Jan 27, 2015 at 16:29

1 Answer 1

6

Looks like you database is Accent Insensitive.

You need to explicitly mention the proper collation name in where clause to filter the proper data.

Use Latin1_General_100_CI_AS collation which is accent sensitive. Try this.

SELECT *
FROM   [UserType]
WHERE  type = CONVERT(NVARCHAR(50), N'វិច្ឆិកា') COLLATE Latin1_General_100_CI_AS; 
Sign up to request clarification or add additional context in comments.

2 Comments

It's working fine now , But I don't want to use COLLATE Latin1_General_100_CI_AS in the query.Is there any way?
@ChhornSoro - Try altering your database collation

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.