Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- update contObj
- set contObj.objectIsDeleted = 1
- from t_objects contObj
- inner join t_contacts cont on cont.contactID = contObj.objectID
- where contObj.objectIsDeleted = 0
- and not exists (select *
- from t_contracts contr
- inner join t_objects contrObj on contrObj.objectID = contr.ContractID
- where contrObj.objectIsDeleted = 0 and contr.ContactID = contObj.objectID)
- and (select COUNT(*) from t_contracts where ContactID = contObj.objectId) > 0
Add Comment
Please, Sign In to add comment