views:

349

answers:

3

I am using SQL Server 2008 express edition and its collation settings are set to default.I wish to store special characeters like á ,â ,ã ,å ,ā ,ă ,ą ,ǻ in my database but it converts them into normal characters like 'a'. How can I stop SQL Server from doing so?

+3  A: 

Make sure that your columns are using the type nvarchar(...), rather than varchar(...). The former is Unicode, the latter is ASCII.

Also, make sure that your database default collation is set to Accent Sensitive, and that your columns are stored that way. You may also want to check your instance default collation, as that affects the default collation for your system databases, particularly tempdb.

Rob Farley
Thanks for the response Rob....but that doesn't seem to help...I have set the collation to german and checked the accent sensitive option...additionally all my columns in the concerned table are nvarchar...still conversion is taking place....Am I doing nethng wrong?
Rahul
@Rahul - how are you actually putting values into the database? Could the conversion be happening up the chain (like in the application)?
Damovisa
As of now i m just running direct queries in the database...so it isnt regarding the app yet...
Rahul
Can you check what the collation on the columns actually is? Query sys.columns and see for me?
Rob Farley
Also show how you are "just running direct queries in the database"... using Management Studio? Can you show your exact INSERT statements, and as Rob asked, sys.columns output for the table?
Aaron Bertrand
A: 

Rahul, here is a very simple query that runs perfectly on SQL 2005 and 2008:

Query

DECLARE @t1 TABLE (
    Col1    nvarchar(30)
)

INSERT INTO @t1 VALUES (N'á ,â ,ã ,å ,ā ,ă ,ą ,ǻ')

SELECT * FROM @t1

Result

Col1
------------------------------
á ,â ,ã ,å ,ā ,ă ,ą ,ǻ

There is nothing special here. No collation change from default, just a simple NVARCHAR column.

You said you are "just running direct queries in the database". Can you try this query and see if you get the same results?

Rob Garrison
A: 

Thnk you very much.......:)

Can you explain me for y we need to pass 'N' before special characters.

satya