Home

DELETE and UPDATE statements should contain WHERE clauses

Rule description

  • DELETE and UPDATE statements should contain WHERE clauses

 

Non-compliant Code Example

DELETE FROM Production.ProductCostHistory;  --Non compliant code (Where clause is missing)
UPDATE Person.Address  --Non compliant code (Where clause is missing)
SET ModifiedDate = GETDATE();

Compliant Code Example

DELETE FROM Production.ProductCostHistory  --Compliant code
Where costId = 152;
UPDATE Person.Address  --Compliant code
SET ModifiedDate = GETDATE()
Where id = 190;
Visual Expert 2020
 VETSQLRULE2