tsql 更改字段排序规则_SQL Server:列排序规则对T-SQL指令的影响

bd96500e110b49cbb3cd949968f18be7.png

I discovered(*) today that, depending on the server, my TSQL commands were case-sensitive, meaning that, when one table's column is named tableId, the following instruction might not succeed:

SELECT TableId FROM myTable

Depending on the column's collation. SQL_Latin1_blablabla seems not to be case-sensitive, when Latin1_blablabla is.

So my first question is WHY!!!

And the second one is: what is the quickest trick (sp?) to change all collations for all concerned columns in the database?

EDIT: to make things very clear:

SELECT tableId FROM myTable

Work on all servers while

SELECT TableId FROM myTable

Works only on the server with the SQL_Latin_blablabla collation. Notice the difference between the 2 strings. We are not talking here about data collation, but about the impact of this collation on the way we write code!

(*) I could use here some additional and specific word to qualify my state of mind after this 'discovery', but all of them are adult-rated ...

解决方案

Following on from marc_s

sys.objects, sys.columns etc store the column names and object names in the collation of the database. So, a binary collation means object names treated as binary...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值