T-SQL Tutorial

Msg 1911 Level 16 - Column name does not exist in the target table or view


Transact sql error message Msg 1911 Level 16 - Column name does not exist in the target table or view - means that you write invalid name column.

Msg 1911 Level 16 Example:

USE model;
GO
CREATE TABLE students( id INT NOT NULL, first_name CHAR(50), last_name CHAR(50),
gender CHAR(1), city CHAR(100), country CHAR(50), dep_id INT);
GO

Invalid alter table:

USE model;
GO
ALTER TABLE students ADD PRIMARY KEY (id123) ;
GO

Message
Msg 1911, Level 16, State 1, Line 1
Column name 'id123' does not exist in the target table or view.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.

Correct alter table:

USE model;
GO
ALTER TABLE students ADD PRIMARY KEY (id) ;
GO

Message
Command(s) completed successfully.

Other error messages: