UPDATE
and DELETE
statements should contain WHERE
clauses to keep the modification of records under control.
Otherwise unexpected data loss could result.
Noncompliant code example
DELETE FROM countries
UPDATE employee SET status = 'retired' FROM table1 AS employee
Compliant solution
TRUNCATE TABLE countries
DELETE FROM countries WHERE CODE = @country_code
UPDATE employee SET status = 'retired' FROM table1 AS employee WHERE age > @maxAge
Exceptions
No issue is reported for statements made on temporary tables.