• 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%'

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]