SQL Azure - 无法更改列类型

时间:2011-11-25 07:36:57

标签: sql-server-2008-r2 azure-sql-database

今天我在SQL Azure门户中创建了一个新表,默认情况下有一个Id INT列。

Id ( int , PK , Not Null)

当我尝试将其更改为BIGINT时,它给了我以下错误:

An error was encountered while applying the changes.An exception occurred
while executing the Transact-SQL statement:
ALTER TABLE [dbo].[PerformanceData]
ALTER COLUMN [Id] BIGINT NOT NULL.
The object 'PrimaryKey_029c7a8d-e6b2-43b8-94f1-98fc5b0115e3' is dependent on
column 'Id'. ALTER TABLE ALTER COLUMN Id failed because one or more objects
access this column.

为什么会这样?

1 个答案:

答案 0 :(得分:1)

您尝试更改的列似乎是主键列。您需要先删除相关约束。这样的事情:ALTER TABLE [dbo].[PerformanceData] DROP CONSTRAINT Id