问题
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