%ls failed because column ‘%.*ls’ does not exist in table ‘%.*ls’.

Error Message:
Msg 4924, Level 16, State 1, Line 1
%ls failed because column ‘%.*ls’ does not exist in table ‘%.*ls’.

Severity level:
16.

Description:
This error message appears when you try to drop a column via ALTER TABLE DROP COLUMN from a table, that does not exist in this table.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
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 can only drop columns from a table that do exist in that table.

Versions:
All versions of SQL Server.

Example(s):
USE tempdb;
GO
IF OBJECT_ID(‘tempdb..#t’) > 0
 DROP TABLE #t
GO
CREATE TABLE #t
(
 id INT PRIMARY KEY
)
GO
ALTER TABLE #t DROP COLUMN c1

Remarks:
In the above example we try to drop the non-existing column c1 from the table #t. This raises the error.




Array

No comments yet... Be the first to leave a reply!