SQL Server 2005 collation issue

自作多情 提交于 2019-12-22 12:49:11

问题


I have two tables, and they are using different collations. It is not allowed to concatenate columns from tables with different collations, for example the following SQL is not allowed,

select table1column1 + table2column2 from ...

My question is, how to change the collation of a table without destroying the data of the table?

thanks in advance, George


回答1:


You can change columns collation on the fly if you need to.

E.g.

select table1column1 collate database default  + table2column2 collate database default from ...

"Database default" could be whatever the collation you are wanting to use.

You can alter the collation of a column permanently with

ALTER TABLE ... ALTER COLUMN Table1Column1
            varchar(50) COLLATE Latin1_General_CI_AS NOT NULL
GO


来源:https://stackoverflow.com/questions/844896/sql-server-2005-collation-issue

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