Allow special characters SQL Server 2008

左心房为你撑大大i 提交于 2019-12-19 18:28:27

问题


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?



来源:https://stackoverflow.com/questions/1628957/allow-special-characters-sql-server-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!