Specific error message,
Message 5074, level 16, state 1, 2nd rows
The object 'price' depends on the column 'price '.
Message 4922, level 16, status 9, 2nd rows
Alter table alter column price failed because one or more objects access this column.
Modification fails because of check constraints in the table.
The correct method is to delete the constraint, modify it, and add the constraint.
Eg.
1 create table # books 2 3 (4 5 Id int primary key, 6 7 name nvarchar (50) not null, 8 9 price numeric (4) Check (price between 20 and 50) 10 11)
If I want to change the price data type to float
Alter table books
Alter column price float (2)
The above error is reported.
1. Delete the constraint first
You can delete a table by using the Table Designer.
2. Modify alter table books alter column price nvarchar (10)
3. Add the check constraint alter table books add constraint price_r check (price> = 20 and price <= 50)
An error occurred while modifying fields in the table.