declare @EntID int
select @EntID = EntityID
from VCLib.T_ENTITIES
where EntName = 'FRVICH_PATIENT_COMMON' and [Schema] = 'AKUZ'

delete cl
from VCLib.T_USER_COLUMNS cl
where exists (select * from VCLib.T_USER_CONTEXTS cx where cx.UserContextID = cl.UserContextID and cx.EntityID = @EntID)

delete from EHR.T_EHR_REFERENCE where Entities = @EntID
delete from VCLib.T_USER_CONTEXTS where EntityID = @EntID
delete from VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntID
delete from VCLib.T_ENTITIES where EntityID = @EntID