在SQL Azure数据库区分大小写列名 [英] Case Sensitive column names in Sql Azure Database

查看:257
本文介绍了在SQL Azure数据库区分大小写列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

永远我用在SQL服务器(SQL_Latin1_General_CP1_CS_AS)区分大小写的排序规则。我想移动到SQL Azure数据库和我碰到意想不到的问题。它看起来像它不可能有区分大小写列名。可这是真的吗?

Forever I've used a case sensitive collation in Sql Server (SQL_Latin1_General_CP1_CS_AS). I'm trying to move to Sql Azure Database and I've run into an unexpected problem. It looks like it's impossible to have case sensitive column names. Can this be true?

我创建的数据库...

I create my database...

CREATE DATABASE MyDatabase
COLLATE SQL_Latin1_General_CP1_CS_AS

和创建我的表...

CREATE TABLE [MyTable]
(
    [Name] NVarChar (4000) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
    [name] NVarChar (4000) COLLATE SQL_Latin1_General_CP1_CS_AS NULL                                                                                
)

和我得到的错误:
每个表中的列名必须是唯一的。列名'名'表'MyTable的'被指定了多次。

And I get the error: Column names in each table must be unique. Column name 'name' in table 'MyTable' is specified more than once.

唉,灾难。这工作完全在SQL Server 2012中但是SQL Azure上我似乎无法做到这一点。有谁知道这是为什么不能在SQL Azure中工作吗?有谁知道我怎么能在SQL Azure中这项工作?谢谢你。

Ugh, disaster. This works perfectly in Sql Server 2012. However on Sql Azure I can't seem to make it happen. Does anyone know why this is not working in Sql Azure? Does anyone know how I can make this work in Sql Azure? Thanks.

推荐答案

我觉得这是在Windows Azure中SQL的错误!

在在线文档的状态,您可以在数据库,列或前pression级别覆盖的排序规则。你不能在服务器级别做到这一点。

On line documentation states that you can override the collation at the database, column or expression levels. You can not do it at the server level.

<一个href=\"http://msdn.microsoft.com/en-us/library/windowsazure/ee336245.aspx#sscs\">http://msdn.microsoft.com/en-us/library/windowsazure/ee336245.aspx#sscs

让我们开始,我们知道将工作的东西,一个本地安装SQL Server 2012。

Lets start with something we know will work, a local install of SQL Server 2012.

-- Start at master
Use master;
Go

-- Create a new database
CREATE DATABASE Koopa
  COLLATE SQL_Latin1_General_CP1_CS_AS;

-- Use the new database
Use Koopa;
Go

-- Create a new table
CREATE TABLE [MyTable]
(
    [ColName1] NVarChar (4000) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
    [colname1] NVarChar (4000) COLLATE SQL_Latin1_General_CP1_CS_AS NULL                                                                                
);

如果我们尝试运行在master数据库中创建表,我们得到您的错误。

If we try to run the create table in the MASTER database, we get your error.

消息2705,级别16,状态3,行2

Msg 2705, Level 16, State 3, Line 2

列名必须是唯一的。列名表'colname1'MyTable的'被指定了多次。

Column names in each table must be unique. Column name 'colname1' in table 'MyTable' is specified more than once.

如果我们在库巴数据库中运行创建表,它工作正常。参见下图。这是因为主不区分大小写CI!

If we run the create table in the Koopa database, it works fine. See image below. That is because MASTER is Case Insensitive CI!

我要使用Azure的SQL数据库的Web界面,因为它有漂亮的颜色(它是Web)!

I am going to use the Web Interface for Azure SQL database since it has nice colors (it is the web)!

让我们创建具有区分大小写归类的新数据库。哇,我越来越兴奋,因为有选择我们整理一个选项。

Let's create a new database with the Case Sensitive collation. Wow I am getting excited since there is an option to select our collation.

现在我们有了一个新的数据库,让检查设置!

Now that we have a new database, lets check the settings!

我还是很开心,因为我们看到的数据库中列出的正确的排序规则。

I am still happy since we see the correct collation listed for the database.

让我们登录到数据库服务器直接与运行一个简单的查询来创建表。

Lets log onto the database server directly and run a simple query to create the table.

我要首先尝试的设计师!

I am going to try the designer first!

哎呀,它没有工作。

让我们试着在查询窗口一个简单的DDL语句。

Lets try a simple DDL statement in a query window.

现在我真的很失望。:我们售出商品的法案,但SQL Azure的没有提供。

Now I am really disappointed. We were sold a bill of goods but Azure SQL did not deliver.

总之,文件说,你不能设置排序在服务器级别。

In short, the documentation says you can not set the collation at the server level.

<一个href=\"http://technet.microsoft.com/en-us/library/ms143726.aspx\">http://technet.microsoft.com/en-us/library/ms143726.aspx

不过,从BOL这句话指出,我们应该能够在骑在数据库级别。

However, this Quote from BOL states we should be able to over ride it at the database level.

服务器级排序规则
默认的服务器排序规则的SQL Server安装过程中设置,并且也成为系统数据库和所有用户数据库的默认排序规则。需要注意的是统一code-只排序规则不能SQL Server安装过程中选择,因为它们不支持作为服务器级排序规则。

在总之,我有一对夫妇的演讲为PASS未来7天忙得不亦乐乎。我会打开一个错误报告或查看是否有一个已经打开。

In short, I am extremely busy with a couple speaking engagements for PASS the next 7 days. I will have to open a bug report or see if there is one already open.

好找!

顺便说一句 - 你现在需要使用不同的列名

BTW - You now need to use distinct column names.

这篇关于在SQL Azure数据库区分大小写列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆