SQL Server 脚本大小写

本文探讨了SQL Server中标识符的大小写敏感性问题,并解释了不同层级对象标识符的排序规则如何影响存储过程及其它数据库对象。了解这些规则有助于避免因大小写不一致引发的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天安装程序,发现在创建存储过程的时候报错。仔细分析一下,发现是存储过程的变量大小写不一致。于是,开始研究是什么配置决定的。

最后发现是随着sql server实例的配置变化。换句话说,数据的大小写可以在每个库中控制,甚至按字段控制。但是,sql脚本就不行了。

 

下面是从MSDN里面抄出来。

SQL Server 2005/2008的标识符的排序规则取决于定义标识符的级别。为实例级对象(如登录名和数据库名)的标识符指派的是实例的默认排序规则。为数据库对象(如表、视图和列名)的标识符指派的是数据库的默认排序规则。连接上下文与一个数据库关联后,可以创建变量、GOTO 标签、临时存储过程和临时表;该上下文切换到其他数据库时,可以引用它们。因此,变量、GOTO 标签和临时表的标识符使用实例的默认排序规则。

 

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. 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. Therefore, the identifiers for variables, GOTO labels, and temporary tables are in the default collation of the instance.

 

学无止境!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值