When you
issue an INSERT command, it is best to explicitly specify the column names of
the table you are inserting into. However, if you omit those target column
names, you must ensure that the order of values that you are inserting matches
the order that the columns were presented when the table was defined.
There is a
way to create a table based on the result of a SQL query. That is done with the
SELECT INTO statement. This will copy IDENTITY values from the source table.
However it does not copy any of the following properties of the source table:
·
Indexes
·
Triggers
·
Permissions
·
Constraints
The simple
UPDATE statement is normally dealing with a single that that gets some changes.
However, you can perform on update on a JOIN of multiple tables. The only
caveat is that only one of those tables can be affected with changes. You can
also use a CTE in your update statement if it makes your life easier.
TRUNCATE is an operation that is related to
DELETE. There are some differences though. It is much faster than a DELETE. It
resets the IDENTITY column if there is one. The TRUNCATE will not work if there
are any foreign keys present in the data of the table you are truncating. The
TRUNCATE affects all rows of the table. You cannot TRUNCATE just a portion of a
table like DELETE can.