简体   繁体   English

SQL Server 2005排序规则问题

[英]SQL Server 2005 collation issue

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, 不允许串联来自具有不同排序规则的表中的列,例如,不允许使用以下SQL,

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 预先感谢乔治

You can change columns collation on the fly if you need to. 您可以根据需要随时更改列排序规则。

Eg 例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM