ALTER TABLE on dependent column

前端 未结 3 1841
抹茶落季
抹茶落季 2021-02-01 01:03

I am trying to alter column datatype of a primary key to tinyint from int.This column is a foreign key in other tables.So,I get the following error:


3条回答
  •  日久生厌
    2021-02-01 01:43

    If your constraint is on a user type, then don't forget to see if there is a Default Constraint, usually something like DF__TableName__ColumnName__6BAEFA67, if so then you will need to drop the Default Constraint, like this:

    ALTER TABLE TableName DROP CONSTRAINT [DF__TableName__ColumnName__6BAEFA67]
    

    For more info see the comments by the brilliant Aaron Bertrand on this answer.

提交回复
热议问题