Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT I.UnitId
- FROM #Inserts AS I
- WHERE NOT EXISTS (
- SELECT 1
- from #Inserts AS INS
- INNER JOIN Organisation AS O
- ON INS.OrganisationId = O.OrganisationId
- AND INS.UnitId = O.UnitId
- )
- DELETE INS FROM #Inserts AS INS
- INNER JOIN Organisation AS O
- ON INS.OrganisationId = O.OrganisationId
- AND INS.UnitId = O.UnitId
- SELECT I.UnitId
- FROM #Inserts I
- WHERE NOT EXISTS (SELECT 1
- FROM Organisation AS O
- WHERE I.OrganisationId = O.OrganisationId AND I.UnitId = O.UnitId
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement