dwilliscp (11/14/2012)
Why does this delete all my records, reguardless of company?delete Plant_Master
where EXISTS(Select Plant_CD from Plant_Master where company like 'MSC')
does at least one row exist in Plant_Master where company = 'MSC'?
If so then EXISTS(Select Plant_CD from Plant_Master where company like 'MSC') evaluates to true and all records from Plant_Master are deleted.
If you want to delete records from Plant_Master where company = 'MCS' then you need to do :
delete Plant_Master
where company = 'MSC'
If you want to delete records from Plant_Master where company strats from 'MCS' then you need to do :
delete Plant_Master
where company LIKE 'MSC%'
If you want to delete records from Plant_Master where company contains 'MCS' then you need to do :
delete Plant_Master
where company LIKE '%MSC%'