User Tools

Site Tools


notes:sql:delete

DELETE statement

-- Example #1
DELETE FROM #customers WHERE CustomerType IS NOT NULL
 
-- Example #2
-- Delete inactive customers if there are still any active ones.
DELETE FROM #customers
WHERE IsActive=0
AND EXISTS (SELECT CustomerId 
            FROM #customers cust 
            WHERE cust.IsActive=1 
            AND cust.CustomerId=#customers.CustomerId)
notes/sql/delete.txt · Last modified: 2015/06/24 by admin