In addition to the SELECT statement, which was introduced earlier in chapter “Queries“, there are three other DML statements: INSERT, UPDATE, and DELETE. Like the SELECT statement, these three modification statements operate either on tables or on views. This chapter discusses these statements in relation to tables and gives examples of their use. Additionally, it… [Continue Reading]
Modification of a Table's Contents
UPDATE Statement (Modifying Data) in SQL Server 2012
The UPDATE statement modifies values of table rows. This statement has the following general form: UPDATE tab_name { SET column_1 = {expression | DEFAULT | NULL} [,…n] [FROM tab_name1 [,…n]] [WHERE condition] Rows in the tab_name table are modified in accordance with the WHERE clause. For each row to be modified, the UPDATE statement changes… [Continue Reading]
DELETE Statement – Deleting rows – SQL Server 2012
The DELETE statement deletes rows from a table. This statement has two different forms: DELETE FROM table_name [WHERE predicate]; DELETE table_name FROM table_name [,…n] [WHERE condition]; All rows that satisfy the condition in the WHERE clause will be deleted. Explicitly naming columns within the DELETE statement is not necessary (or allowed), because the DELETE… [Continue Reading]
TRUNCATE TABLE, MERGE & OUTPUT Clause – SQL Server 2012
TRUNCATE TABLE Statement The Transact-SQL language also supports the TRUNCATE TABLE statement. This statement normally provides a “faster executing” version of the DELETE statement without the WHERE clause. The TRUNCATE TABLE statement deletes all rows from a table more quickly than does the DELETE statement because it drops the contents of the table page by… [Continue Reading]