Reputation: 17
Can someone tell me how to remove the dependency.
Alter Table NYM_Player_Stats
Alter Column SO char(38)
Msg 5074, Level 16, State 1, Line 4
The object 'SO_Not_Null' is dependent on column 'SO'.Msg 4922, Level 16, State 9, Line 4
ALTER TABLE ALTER COLUMN SO failed because one or more objects access this column.
Table structure:
Team (PK, nchar(10), not null)
Year (nchar (10), not null)
SO (numeric (18,0)
AB (char (38), not null)
Runs (char (38) not null)
Hits (char(38) not null)
Upvotes: 0
Views: 2323
Reputation: 8699
Ran select TYPE from sys.objects where NAME='so_not_null' and the results are Type 1 C
A type of C
indicates that SO_NOT_NULL is a check constraint. To alter the column definition, you will need to first remove the constraint. The constraint can be recreated after the column is altered.
To do so, complete the following steps:
SELECT DEFINITION FROM SYS.CHECK_CONSTRAINTS WHERE NAME='so_not_null'
to get the constraint definition. Save the output.ALTER TABLE NYM_PLAYER_STATS DROP CONSTRAINT SO_NOT_NULL
.ALTER TABLE
statement in your original question to update the column definition.ALTER TABLE NYM_PLAYER_STATS ADD CONSTRAINT SO_NOT_NULL CHECK (<STATEMENT>)
, replacing <STATEMENT>
with the definition from step 1.Upvotes: 1