SQL Azure - Could not able to alter column type

空扰寡人 提交于 2019-12-11 06:49:24

问题


Today I created a new table in SQL Azure portal and by default there is an Id INT column.

Id ( int , PK , Not Null)

When I tried to change it to BIGINT it gave me the following error:

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.

Why did this happen?


回答1:


Looks like the column you are trying to alter is the primary key column. You need to drop related constraints first. Something like this:ALTER TABLE [dbo].[PerformanceData] DROP CONSTRAINT Id



来源:https://stackoverflow.com/questions/8265992/sql-azure-could-not-able-to-alter-column-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!