Msg 4922, Level 16, State 9, Line 1
%ls %.*ls failed because one or more objects access this column.
This error message appears when you try to drop a column via ALTER TABLE DROP COLUMN, however other objects, such as constraints, do reference the column.
The T-SQL statement can be parsed, but causes the error at runtime.
Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must first drop the referencing objects before the column can be dropped.
All versions of SQL Server.
IF OBJECT_ID(‘tempdb..#t’) > 0
DROP TABLE #t
CREATE TABLE #t
id INT PRIMARY KEY
ALTER TABLE #t DROP COLUMN id
In the above example we try to drop the column c1 of the table #t. Because there is a PRIMARY KEY constraint that accesses the column c1, the error is raised.
In order to successfully complete this statement, you first need to drop the PRIMARY KEY constraint, before you can drop the column.]]>