Mega Code Archive

 
Categories / MSSQL Tutorial / Insert Delete Update
 

The order of column names in the VALUE clause of the INSERT statement can be different from the original order of tho

6>  CREATE TABLE employee( 7>    id          INTEGER NOT NULL PRIMARY KEY, 8>    first_name  VARCHAR(10), 9>    last_name   VARCHAR(10), 10>    salary      DECIMAL(10,2), 11>    start_Date  DATETIME, 12>    region      VARCHAR(10), 13>    city        VARCHAR(20), 14>    managerid   INTEGER 15> ); 16> GO 1> INSERT INTO employee (id) VALUES (3); 2> GO (1 rows affected) 1> 2> select * from employee; 3> GO id          first_name last_name  salary       start_Date              region     city                 managerid ----------- ---------- ---------- ------------ ----------------------- ---------- -------------------- -----------           3 NULL       NULL               NULL                    NULL NULL       NULL                        NULL (1 rows affected) 1> 2> 3> INSERT INTO employee (first_name, id) VALUES (1,'Davis') 4> 5> 6> 7> 8> drop table employee; 9> GO Msg 245, Level 16, State 1, Server J\SQLEXPRESS, Line 3 Conversion failed when converting the varchar value 'Davis' to data type int.