简体   繁体   中英

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,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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