Guest User

Untitled

a guest
Aug 7th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.46 KB | None | 0 0
  1. update contObj
  2. set contObj.objectIsDeleted = 1
  3. from t_objects contObj
  4.     inner join t_contacts cont on cont.contactID = contObj.objectID
  5. where contObj.objectIsDeleted = 0
  6.     and not exists (select *
  7.                     from t_contracts contr
  8.                         inner join t_objects contrObj on contrObj.objectID = contr.ContractID
  9.                     where contrObj.objectIsDeleted = 0 and contr.ContactID = contObj.objectID)
  10.     and (select COUNT(*) from t_contracts where ContactID = contObj.objectId) > 0
Add Comment
Please, Sign In to add comment