Cannot resolve collation conflict for equal to operation.

   这个是books online上面对collate的定义,今天在帮同事解决一个数据库问题的时候遇到了Cannot resolve collation conflict for equal to operation.这个问题,

update  sec_usrdata
set  userID  =  new_ID
from  sec_usrdata, Map_Table
where  userID  =  old_id

其中sec_userdate表建表的时候对字符有COLLATE Chinese_Taiwan_Stroke_CI_AS的要求,而Map_Table建立表的时候却没有添加这个语句,导致数据更新出错。另外好久都没有写script的脚本,都忘记update后面可以加from的,汗~~贴上来做保存了^^

 

COLLATE
A clause that can be applied to a database definition or a column definition to define the collation, or to a character string expression to apply a collation cast.
Syntax
COLLATE < collation_name >
< collation_name > :: =
    { Windows_collation_name } | { SQL_collation_name }
Arguments
collation_name
Is the name of the collation to be applied to the expression, column definition, or database definition. collation_name can be only a specified Windows_collation_name or a SQL_collation_name.
Windows_collation_name
Is the collation name for Windows collation. See Windows Collation Names.
SQL_collation_name
Is the collation name for a SQL collation. See SQL Collation Names.
Remarks
The COLLATE clause can be specified at several levels, including the following:
  1. Creating or altering a database.
You can use the COLLATE clause of the CREATE DATABASE or ALTER DATABASE statement to specify the default collation of the database. You can also specify a collation when you create a database using SQL Server Enterprise Manager. If you do not specify a collation, the database is assigned the default collation of the SQL Server instance.
  1. Creating or altering a table column.
You can specify collations for each character string column using the COLLATE clause of the CREATE TABLE or ALTER TABLE statement. You can also specify a collation when you create a table using SQL Server Enterprise Manager. If you do not specify a collation, the column is assigned the default collation of the database.
You can also use the database_default option in the COLLATE clause to specify that a column in a temporary table use the collation default of the current user database for the connection instead of tempdb.
  1. Casting the collation of an expression.
You can use the COLLATE clause to cast a character expression to a certain collation. Character literals and variables are assigned the default collation of the current database. Column references are assigned the definition collation of the column.  For the collation of an expression, see Collation Precedence.
The collation of an identifier depends on the level at which it is defined. Identifiers of instance-level objects, such as logins and database names, are assigned the default collation of the instance. Identifiers of objects within a database, such as tables, views, and column names, are assigned the default collation of the database. For example, two tables with names differing only in case may be created in a database with case-sensitive collation, but may not be created in a database with case-insensitive collation.
Variables, GOTO labels, temporary stored procedures, and temporary tables can be created when the connection context is associated with one database, and then referenced when the context has been switched to another database. The identifiers for variables, GOTO labels, temporary stored procedures, and temporary tables are in the default collation of the instance.
The COLLATE clause can be applied only for the char, varchar, text, nchar, nvarchar, and ntext data types.
Collations are generally identified by a collation name. The exception is in Setup where you do not specify a collation name for Windows collations, but instead specify the collation designator, and then select check boxes to specify binary sorting or dictionary sorting that is either sensitive or insensitive to either case or accents.
You can execute the system function fn_helpcollations to retrieve a list of all the valid collation names for Windows collations and SQL collations:
SELECT *
FROM ::fn_helpcollations()
SQL Server can support only code pages that are supported by the underlying operating system. When you perform an action that depends on collations, the SQL Server collation used by the referenced object must use a code page supported by the operating system running on the computer. These actions can include:
  • Specifying a default collation for a database when you create or alter the database.
  • Specifying a collation for a column when creating or altering a table.
  • When restoring or attaching a database, the default collation of the database and the collation of any char, varchar, and text columns or parameters in the database must be supported by the operating system.
Code page translations are supported for char and varchar data types, but not for text data type. Data loss during code page translations is not reported.
If the collation specified or the collation used by the referenced object, uses a code page not supported by Windows®, SQL Server issues error. For more information, see the Collations section in the SQL Server Architecture chapter of the SQL Server Books Online.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值