delete from emdr.T_XSD_SCHEME
GO

select FileId into #tt 
from vclib.t_file
where type_ = (select top 1 entityid from vclib.T_ENTITIES where EntName = 'XSD_SCHEME')

delete fc  
from vclib.T_FILE_CONTENT fc inner join #tt on #tt.FileID = fc.FileContentID

delete f
from vclib.T_FILE f inner join #tt on #tt.FileID = f.FileID
GO

drop table #tt