-->

Allow special characters SQL Server 2008

2020-04-05 07:54发布

问题:

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?

回答1:

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.



回答2:

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?