SQL Server Error messages - Msg 213 - Insert Error: tower name or variety of supplied worths does not enhance table definition.
SQL Server Error message - Msg 213
Server: Msg 213, Level 16, State 1, heat 1Insert Error: pillar name or number of supplied values does not complement table definition. Causes:
This error occurs once doing an INSERT where the columns perform is not specified and the worths being inserted, either v the values clause or with a select subquery, room either more than or much less than thecolumns in the table. Here are examples on when the error have the right to occur:
-- Sample #1: utilizing INSERT into ... VALUESCREATE TABLE . ( INT, VARCHAR(100))INSERT right into .VALUES (1, "John", "Doe")-- Sample #2: using INSERT into ... Select FROMCREATE TABLE . ( INT, VARCHAR(100))INSERT right into .SELECT , , FROM . solution / work Around:
To stop this problem, make certain that the values mentioned in the worths clause or in the select subquery enhance the number of columns in the INSERT clause. In enhancement to this,you mustspecify the columns in the INSERT right into clause. Back the column list in the INSERT right into statement is optional, it is recommended the it is always specified so that also if there are any modifications make on the table, either brand-new columns are included or inserted in the middle of the table or columns are deleted, the INSERT statement will not create this error. (Of course, a different error message will be generated if a column is turned off from the table that is gift referenced by the INSERT statement).
Given the samples above, here"s how to prevent the error:
-- Sample #1: making use of INSERT into ... VALUESCREATE TABLE . ( INT, VARCHAR(100))INSERT right into . ( , )VALUES (1, "John Doe")-- Sample #2: utilizing INSERT into ... Pick FROMCREATE TABLE . ( INT, VARCHAR(100))INSERT into .