今天我在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.
为什么会这样?
答案 0 :(得分:1)
您尝试更改的列似乎是主键列。您需要先删除相关约束。这样的事情:ALTER TABLE [dbo].[PerformanceData] DROP CONSTRAINT Id