declare @userid int = 9 -- codi de l'usuari del que volem esborrar tots els missatges entrants

delete AD 
from ALR1 AD
join OAIB A on A.AlertCode=AD.Code and A.UserSign=@userid

delete AD 
from ALR2 AD
join OAIB A on A.AlertCode=AD.Code and A.UserSign=@userid

delete AD 
from ALR3 AD
join OAIB A on A.AlertCode=AD.Code and A.UserSign=@userid

delete AD 
from OALR AD
join OAIB A on A.AlertCode=AD.Code and A.UserSign=@userid

delete from OAIB where UserSign=@userid

 

image_pdf