declare @entName varchar(255)
select @entName = 'PLAN_REQUEST_SMO_ITEM'

delete from VCLib.T_EXTRA_TEMPLATE
from VCLib.T_EXTRA_TEMPLATE
inner join VCLib.T_FILE on VCLib.T_EXTRA_TEMPLATE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_FILE_RIGHTS
from VCLib.T_GENERIC_REPORT_FILE_RIGHTS
inner join VCLib.T_FILE on VCLib.T_GENERIC_REPORT_FILE_RIGHTS.GenericReportFile=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_TEMPLATE
from VCLib.T_GENERIC_REPORT_TEMPLATE
inner join VCLib.T_FILE on VCLib.T_GENERIC_REPORT_TEMPLATE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_FILE_REPORT_MENU_ITEM
from VCLib.T_FILE_REPORT_MENU_ITEM
inner join VCLib.T_FILE on VCLib.T_FILE_REPORT_MENU_ITEM.GenericReportFile=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_XML_REPORT_FILE
from VCLib.T_XML_REPORT_FILE
inner join VCLib.T_FILE on VCLib.T_XML_REPORT_FILE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_XML_REPORT_TEMPLATE
from VCLib.T_XML_REPORT_TEMPLATE
inner join VCLib.T_FILE on VCLib.T_XML_REPORT_TEMPLATE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ReportFile
from VCLib.T_ReportFile
inner join VCLib.T_FILE on VCLib.T_ReportFile.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADDING_DOCUMENT_FILE
from VCLib.T_ADDING_DOCUMENT_FILE
inner join VCLib.T_FILE on VCLib.T_ADDING_DOCUMENT_FILE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_TEMPLATE
from VCLib.T_EXPORT_TEMPLATE
inner join VCLib.T_FILE on VCLib.T_EXPORT_TEMPLATE.FileID=VCLib.T_FILE.FileID
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_TEMPLATE
from VCLib.T_EXTRA_TEMPLATE
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_TEMPLATE.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_ACTION_PARAMS
from VCLib.T_EXTRA_UI_ACTION_PARAMS
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_UI_ACTION_PARAMS.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_COMMAND_ROLES
from VCLib.T_EXTRA_UI_COMMAND_ROLES
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_UI_COMMAND_ROLES.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_TEMPLATE
from VCLib.T_EXTRA_TEMPLATE
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_TEMPLATE.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_ACTION_PARAMS
from VCLib.T_EXTRA_UI_ACTION_PARAMS
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_UI_ACTION_PARAMS.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_COMMAND_ROLES
from VCLib.T_EXTRA_UI_COMMAND_ROLES
inner join VCLib.T_EXTRA_UI_COMMAND on VCLib.T_EXTRA_UI_COMMAND_ROLES.ExtraUiCommand=VCLib.T_EXTRA_UI_COMMAND.ExtraUiCommandID
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_ATTRIBUTE
from VCLib.T_DICTIONARY_ATTRIBUTE
inner join VCLib.T_DICTIONARY_UPDATE on VCLib.T_DICTIONARY_ATTRIBUTE.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
inner join VCLib.T_ENTITIES on VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_DEPEND
from VCLib.T_DICTIONARY_DEPEND
inner join VCLib.T_DICTIONARY_UPDATE on VCLib.T_DICTIONARY_DEPEND.DependedDictionary=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
inner join VCLib.T_ENTITIES on VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_DEPEND
from VCLib.T_DICTIONARY_DEPEND
inner join VCLib.T_DICTIONARY_UPDATE on VCLib.T_DICTIONARY_DEPEND.DependedDictionary=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
inner join VCLib.T_ENTITIES on VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_USER
from VCLib.T_DICTIONARY_USER
inner join VCLib.T_DICTIONARY_UPDATE on VCLib.T_DICTIONARY_USER.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
inner join VCLib.T_ENTITIES on VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ROLE_ATTRIBUTE_ACCESS
from VCLib.T_ROLE_ATTRIBUTE_ACCESS
inner join VCLib.T_HIDDEN_ATTRIBUTE on VCLib.T_ROLE_ATTRIBUTE_ACCESS.HiddenAttribute=VCLib.T_HIDDEN_ATTRIBUTE.HiddenAttributeID
inner join VCLib.T_ENTITIES on VCLib.T_HIDDEN_ATTRIBUTE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERATOR_LINK
from VCLib.T_GENERATOR_LINK
inner join VCLib.T_GENERIC_REPORT on VCLib.T_GENERATOR_LINK.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERATOR_PARAMS
from VCLib.T_GENERATOR_PARAMS
inner join VCLib.T_GENERIC_REPORT on VCLib.T_GENERATOR_PARAMS.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_FUNCTION
from VCLib.T_GENERIC_REPORT_FUNCTION
inner join VCLib.T_GENERIC_REPORT on VCLib.T_GENERIC_REPORT_FUNCTION.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_MAIN_ITEM
from VCLib.T_GENERIC_REPORT_MAIN_ITEM
inner join VCLib.T_GENERIC_REPORT on VCLib.T_GENERIC_REPORT_MAIN_ITEM.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERATOR_LINK
from VCLib.T_GENERATOR_LINK
inner join VCLib.T_GENERIC_REPORT_GENERATOR on VCLib.T_GENERATOR_LINK.GrCommonGenerator=VCLib.T_GENERIC_REPORT_GENERATOR.GenericReportGeneratorID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GROUP
from VCLib.T_GENERIC_REPORT_GROUP
inner join VCLib.T_GENERIC_REPORT_GENERATOR on VCLib.T_GENERIC_REPORT_GROUP.GrCommonGenerator=VCLib.T_GENERIC_REPORT_GENERATOR.GenericReportGeneratorID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERATOR_LINK
from VCLib.T_GENERATOR_LINK
inner join VCLib.T_GENERIC_REPORT_GENERATOR on VCLib.T_GENERATOR_LINK.GrCommonGenerator=VCLib.T_GENERIC_REPORT_GENERATOR.GenericReportGeneratorID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GROUP
from VCLib.T_GENERIC_REPORT_GROUP
inner join VCLib.T_GENERIC_REPORT_GENERATOR on VCLib.T_GENERIC_REPORT_GROUP.GrCommonGenerator=VCLib.T_GENERIC_REPORT_GENERATOR.GenericReportGeneratorID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GROUPBY
from VCLib.T_GENERIC_REPORT_GROUPBY
inner join VCLib.T_GENERIC_REPORT_GROUP on VCLib.T_GENERIC_REPORT_GROUPBY.GenericReportGroupID=VCLib.T_GENERIC_REPORT_GROUP.GenericReportGroupID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GROUP.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_STATIC_GROUPS
from VCLib.T_STATIC_GROUPS
inner join VCLib.T_GENERIC_REPORT_GROUP on VCLib.T_STATIC_GROUPS.GenericReportGroupID=VCLib.T_GENERIC_REPORT_GROUP.GenericReportGroupID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GROUP.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_MAIN_ITEM
from VCLib.T_GENERIC_REPORT_MAIN_ITEM
inner join VCLib.T_GENERIC_REPORT_MAIN on VCLib.T_GENERIC_REPORT_MAIN_ITEM.GenericReportMain=VCLib.T_GENERIC_REPORT_MAIN.GenericReportMainID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_RIGHTS
from VCLib.T_GENERIC_REPORT_RIGHTS
inner join VCLib.T_GENERIC_REPORT_MAIN on VCLib.T_GENERIC_REPORT_RIGHTS.GenericReportMain=VCLib.T_GENERIC_REPORT_MAIN.GenericReportMainID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_TEMPLATE
from VCLib.T_GENERIC_REPORT_TEMPLATE
inner join VCLib.T_GENERIC_REPORT_MAIN on VCLib.T_GENERIC_REPORT_TEMPLATE.GenericReportMain=VCLib.T_GENERIC_REPORT_MAIN.GenericReportMainID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_ATTACHMENT
from VCLib.T_GENERIC_REPORT_ATTACHMENT
inner join VCLib.T_GENERIC_REPORT_MAIN on VCLib.T_GENERIC_REPORT_ATTACHMENT.GenericReportMain=VCLib.T_GENERIC_REPORT_MAIN.GenericReportMainID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_MENU_ITEM
from VCLib.T_GENERIC_REPORT_MENU_ITEM
inner join VCLib.T_GENERIC_REPORT_MAIN on VCLib.T_GENERIC_REPORT_MENU_ITEM.Report=VCLib.T_GENERIC_REPORT_MAIN.GenericReportMainID
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_COLUMNS
from VCLib.T_USER_COLUMNS
inner join VCLib.T_USER_CONTEXTS on VCLib.T_USER_COLUMNS.UserContextID=VCLib.T_USER_CONTEXTS.UserContextID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_ATTACHMENT
from VCLib.T_GENERIC_REPORT_ATTACHMENT
inner join VCLib.T_EMAIL_ATTACHMENT on VCLib.T_GENERIC_REPORT_ATTACHMENT.EmailAttachmentID=VCLib.T_EMAIL_ATTACHMENT.EmailAttachmentID
inner join VCLib.T_ENTITIES on VCLib.T_EMAIL_ATTACHMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_REPORT_ATTACHMENT
from VCLib.T_REPORT_ATTACHMENT
inner join VCLib.T_EMAIL_ATTACHMENT on VCLib.T_REPORT_ATTACHMENT.EmailAttachmentID=VCLib.T_EMAIL_ATTACHMENT.EmailAttachmentID
inner join VCLib.T_ENTITIES on VCLib.T_EMAIL_ATTACHMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_DATA_MENU_ITEM
from VCLib.T_EXPORT_DATA_MENU_ITEM
inner join VCLib.T_REPORT_MENU_ITEM on VCLib.T_EXPORT_DATA_MENU_ITEM.ReportMenuItemID=VCLib.T_REPORT_MENU_ITEM.ReportMenuItemID
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_FILE_REPORT_MENU_ITEM
from VCLib.T_FILE_REPORT_MENU_ITEM
inner join VCLib.T_REPORT_MENU_ITEM on VCLib.T_FILE_REPORT_MENU_ITEM.ReportMenuItemID=VCLib.T_REPORT_MENU_ITEM.ReportMenuItemID
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_MENU_ITEM
from VCLib.T_GENERIC_REPORT_MENU_ITEM
inner join VCLib.T_REPORT_MENU_ITEM on VCLib.T_GENERIC_REPORT_MENU_ITEM.ReportMenuItemID=VCLib.T_REPORT_MENU_ITEM.ReportMenuItemID
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_SIMPLE_REPORT_MENU_ITEM
from VCLib.T_SIMPLE_REPORT_MENU_ITEM
inner join VCLib.T_REPORT_MENU_ITEM on VCLib.T_SIMPLE_REPORT_MENU_ITEM.ReportMenuItemID=VCLib.T_REPORT_MENU_ITEM.ReportMenuItemID
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_XML_REPORT_MENU_ITEM
from VCLib.T_XML_REPORT_MENU_ITEM
inner join VCLib.T_REPORT_MENU_ITEM on VCLib.T_XML_REPORT_MENU_ITEM.ReportMenuItemID=VCLib.T_REPORT_MENU_ITEM.ReportMenuItemID
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_UNITED_OBJECT_CHANGESET
from VCLib.T_UNITED_OBJECT_CHANGESET
inner join VCLib.T_UNITED_OBJECT on VCLib.T_UNITED_OBJECT_CHANGESET.UnitedObject=VCLib.T_UNITED_OBJECT.UnitedObjectID
inner join VCLib.T_ENTITIES on VCLib.T_UNITED_OBJECT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_Report
from VCLib.T_Report
inner join VCLib.T_BaseReport on VCLib.T_Report.ReportID=VCLib.T_BaseReport.ReportID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ReportRole
from VCLib.T_ReportRole
inner join VCLib.T_BaseReport on VCLib.T_ReportRole.ReportID=VCLib.T_BaseReport.ReportID
inner join VCLib.T_ENTITIES on VCLib.T_BaseReport.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_RSReport
from VCLib.T_RSReport
inner join VCLib.T_BaseReport on VCLib.T_RSReport.ReportID=VCLib.T_BaseReport.ReportID
inner join VCLib.T_ENTITIES on VCLib.T_BaseReport.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_GENERATION
from VCLib.T_NOTIFY_MESSAGE_GENERATION
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_GENERATION.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_OBJECT
from VCLib.T_NOTIFY_MESSAGE_OBJECT
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_OBJECT.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_USER_GROUP
from VCLib.T_NOTIFY_MESSAGE_USER_GROUP
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_USER_GROUP.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_GENERATION
from VCLib.T_NOTIFY_MESSAGE_GENERATION
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_GENERATION.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_OBJECT
from VCLib.T_NOTIFY_MESSAGE_OBJECT
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_OBJECT.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_USER_GROUP
from VCLib.T_NOTIFY_MESSAGE_USER_GROUP
inner join VCLib.T_NOTIFY_MESSAGE_TYPE on VCLib.T_NOTIFY_MESSAGE_USER_GROUP.NotifyMessageType=VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyMessageTypeID
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.EntityType=VCLib.T_ENTITIES.EntityID or VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_SIMPLE_REPORT_MENU_ITEM
from VCLib.T_SIMPLE_REPORT_MENU_ITEM
inner join VCLib.T_Report on VCLib.T_SIMPLE_REPORT_MENU_ITEM.Report=VCLib.T_Report.ReportID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_REPORT_ATTACHMENT
from VCLib.T_REPORT_ATTACHMENT
inner join VCLib.T_Report on VCLib.T_REPORT_ATTACHMENT.Report=VCLib.T_Report.ReportID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ReportFileGroup
from VCLib.T_ReportFileGroup
inner join VCLib.T_Report on VCLib.T_ReportFileGroup.ReportID=VCLib.T_Report.ReportID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ReportKey
from VCLib.T_ReportKey
inner join VCLib.T_Report on VCLib.T_ReportKey.ReportID=VCLib.T_Report.ReportID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DTO_ITEM
from VCLib.T_DTO_ITEM
inner join VCLib.T_DTO_MODEL on VCLib.T_DTO_ITEM.ItemDtoModel=VCLib.T_DTO_MODEL.DtoModelID
inner join VCLib.T_ENTITIES on VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DTO_ITEM
from VCLib.T_DTO_ITEM
inner join VCLib.T_DTO_MODEL on VCLib.T_DTO_ITEM.ItemDtoModel=VCLib.T_DTO_MODEL.DtoModelID
inner join VCLib.T_ENTITIES on VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DTO_MODEL_FILTER
from VCLib.T_DTO_MODEL_FILTER
inner join VCLib.T_DTO_MODEL on VCLib.T_DTO_MODEL_FILTER.DtoModel=VCLib.T_DTO_MODEL.DtoModelID
inner join VCLib.T_ENTITIES on VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DTO_MODEL_VIEW
from VCLib.T_DTO_MODEL_VIEW
inner join VCLib.T_DTO_MODEL on VCLib.T_DTO_MODEL_VIEW.DtoModel=VCLib.T_DTO_MODEL.DtoModelID
inner join VCLib.T_ENTITIES on VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITIES_WEB_ALIAS_ACCESS
from VCLib.T_ENTITIES_WEB_ALIAS_ACCESS
inner join VCLib.T_ENTITIES_WEB_ALIAS on VCLib.T_ENTITIES_WEB_ALIAS_ACCESS.EntitiesWebAlias=VCLib.T_ENTITIES_WEB_ALIAS.Alias
inner join VCLib.T_ENTITIES on VCLib.T_ENTITIES_WEB_ALIAS.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_LEXEM_PARAMETER
from VCLib.T_LEXEM_PARAMETER
inner join VCLib.T_TEMPLATE_OVERRIDE on VCLib.T_LEXEM_PARAMETER.TemplateOverride=VCLib.T_TEMPLATE_OVERRIDE.TemplateOverrideID
inner join VCLib.T_ENTITIES on VCLib.T_TEMPLATE_OVERRIDE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_VALIDATION_CONDITION
from VCLib.T_VALIDATION_CONDITION
inner join VCLib.T_DATAFORM_VALIDATION on VCLib.T_VALIDATION_CONDITION.DataformValidation=VCLib.T_DATAFORM_VALIDATION.Entities
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_VALIDATION.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADD_DOCUMENT_LINK_MODULE
from VCLib.T_ADD_DOCUMENT_LINK_MODULE
inner join VCLib.T_ADDING_DOCUMENT on VCLib.T_ADD_DOCUMENT_LINK_MODULE.AddingDocument=VCLib.T_ADDING_DOCUMENT.AddingDocumentID
inner join VCLib.T_ENTITIES on VCLib.T_ADDING_DOCUMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADD_DOCUMENT_LINK_ROLES
from VCLib.T_ADD_DOCUMENT_LINK_ROLES
inner join VCLib.T_ADDING_DOCUMENT on VCLib.T_ADD_DOCUMENT_LINK_ROLES.AddingDocument=VCLib.T_ADDING_DOCUMENT.AddingDocumentID
inner join VCLib.T_ENTITIES on VCLib.T_ADDING_DOCUMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADDING_DOCUMENT_FILE
from VCLib.T_ADDING_DOCUMENT_FILE
inner join VCLib.T_ADDING_DOCUMENT on VCLib.T_ADDING_DOCUMENT_FILE.AddDocument=VCLib.T_ADDING_DOCUMENT.AddingDocumentID
inner join VCLib.T_ENTITIES on VCLib.T_ADDING_DOCUMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NEWS_BOX_LINK_ADD_DOCUMENT
from VCLib.T_NEWS_BOX_LINK_ADD_DOCUMENT
inner join VCLib.T_ADDING_DOCUMENT on VCLib.T_NEWS_BOX_LINK_ADD_DOCUMENT.AddingDocument=VCLib.T_ADDING_DOCUMENT.AddingDocumentID
inner join VCLib.T_ENTITIES on VCLib.T_ADDING_DOCUMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_PROCESS_ACCESS_ENTRY
from VCLib.T_PROCESS_ACCESS_ENTRY
inner join VCLib.T_BASE_ACCESS_ENTRY on VCLib.T_PROCESS_ACCESS_ENTRY.EntryID=VCLib.T_BASE_ACCESS_ENTRY.EntryID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_BAE_ROLES
from VCLib.T_BAE_ROLES
inner join VCLib.T_BASE_ACCESS_ENTRY on VCLib.T_BAE_ROLES.EntryID=VCLib.T_BASE_ACCESS_ENTRY.EntryID
inner join VCLib.T_ENTITIES on VCLib.T_BASE_ACCESS_ENTRY.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITY_ACCESS_ENTRY
from VCLib.T_ENTITY_ACCESS_ENTRY
inner join VCLib.T_BASE_ACCESS_ENTRY on VCLib.T_ENTITY_ACCESS_ENTRY.EntryID=VCLib.T_BASE_ACCESS_ENTRY.EntryID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENT_ATTR_ACCESS_ENTRY
from VCLib.T_ENT_ATTR_ACCESS_ENTRY
inner join VCLib.T_BASE_ACCESS_ENTRY on VCLib.T_ENT_ATTR_ACCESS_ENTRY.EntryID=VCLib.T_BASE_ACCESS_ENTRY.EntryID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENUM_ACCESS_ENTRY
from VCLib.T_ENUM_ACCESS_ENTRY
inner join VCLib.T_BASE_ACCESS_ENTRY on VCLib.T_ENUM_ACCESS_ENTRY.EntryID=VCLib.T_BASE_ACCESS_ENTRY.EntryID
inner join VCLib.T_ENTITIES on VCLib.T_BASE_ACCESS_ENTRY.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_TEMPLATE_FIELD_VALUE
from VCLib.T_TEMPLATE_FIELD_VALUE
inner join VCLib.T_USERS on VCLib.T_TEMPLATE_FIELD_VALUE.Users=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_SHORTCUTCOMMAND
from VCLib.T_SHORTCUTCOMMAND
inner join VCLib.T_USERS on VCLib.T_SHORTCUTCOMMAND.UserId=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_CONTEXTS
from VCLib.T_USER_CONTEXTS
inner join VCLib.T_USERS on VCLib.T_USER_CONTEXTS.UserID=VCLib.T_USERS.UserID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_SEARCHES
from VCLib.T_USER_SEARCHES
inner join VCLib.T_USERS on VCLib.T_USER_SEARCHES.UserID=VCLib.T_USERS.UserID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USERS_ROLES
from VCLib.T_USERS_ROLES
inner join VCLib.T_USERS on VCLib.T_USERS_ROLES.UserID=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_CONFIG
from VCLib.T_USER_CONFIG
inner join VCLib.T_USERS on VCLib.T_USER_CONFIG.UserID=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_SESSIONS
from VCLib.T_USER_SESSIONS
inner join VCLib.T_USERS on VCLib.T_USER_SESSIONS.UserID=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DELETED_OBJECT
from VCLib.T_DELETED_OBJECT
inner join VCLib.T_USERS on VCLib.T_DELETED_OBJECT.Users=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_XML_REPORT_RESULT
from VCLib.T_XML_REPORT_RESULT
inner join VCLib.T_USERS on VCLib.T_XML_REPORT_RESULT.Users=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_UNITED_OBJECT
from VCLib.T_UNITED_OBJECT
inner join VCLib.T_USERS on VCLib.T_UNITED_OBJECT.BaseUsers=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADDING_DOCUMENT
from VCLib.T_ADDING_DOCUMENT
inner join VCLib.T_USERS on VCLib.T_ADDING_DOCUMENT.Creator=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NEWS_BOX
from VCLib.T_NEWS_BOX
inner join VCLib.T_USERS on VCLib.T_NEWS_BOX.Creator=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NEWS_BOX_LINK_USERS
from VCLib.T_NEWS_BOX_LINK_USERS
inner join VCLib.T_USERS on VCLib.T_NEWS_BOX_LINK_USERS.Users=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_CHANGESETS
from VCLib.T_CHANGESETS
inner join VCLib.T_USERS on VCLib.T_CHANGESETS.UserId=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_JOB
from VCLib.T_JOB
inner join VCLib.T_USERS on VCLib.T_JOB.JobUser=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_TEMPLATE
from VCLib.T_DATAFORM_TEMPLATE
inner join VCLib.T_USERS on VCLib.T_DATAFORM_TEMPLATE.Users=VCLib.T_USERS.UserID
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_IMPORTLOG
from VCLib.T_IMPORTLOG
inner join VCLib.T_USERS on VCLib.T_IMPORTLOG.UserID=VCLib.T_USERS.UserID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_SCHEDULE
from VCLib.T_DICTIONARY_SCHEDULE
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_DICTIONARY_SCHEDULE.OperationID=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EMAIL_MESSAGE
from VCLib.T_EMAIL_MESSAGE
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_EMAIL_MESSAGE.OperationID=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_OPERATION
from VCLib.T_EXPORT_OPERATION
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_EXPORT_OPERATION.OperationID=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_GENERATION
from VCLib.T_NOTIFY_MESSAGE_GENERATION
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_NOTIFY_MESSAGE_GENERATION.OperationID=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_JOB_STEP
from VCLib.T_JOB_STEP
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_JOB_STEP.Operation=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_RUN_LEXEM_OPERATION
from VCLib.T_RUN_LEXEM_OPERATION
inner join VCLib.T_SCHEDULER_OPERATION on VCLib.T_RUN_LEXEM_OPERATION.OperationID=VCLib.T_SCHEDULER_OPERATION.OperationID
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_BASE_FEATURE_SETTINGS
from VCLib.T_BASE_FEATURE_SETTINGS
inner join VCLib.T_CLIENT_MODULE_FEATURE on VCLib.T_BASE_FEATURE_SETTINGS.ClientModuleFeature=VCLib.T_CLIENT_MODULE_FEATURE.ClientModuleFeatureID
inner join VCLib.T_ENTITIES on VCLib.T_CLIENT_MODULE_FEATURE.EntityIndex=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATA_ACCESS_ENTRY
from VCLib.T_DATA_ACCESS_ENTRY
inner join VCLib.T_DATA_ACCESS on VCLib.T_DATA_ACCESS_ENTRY.DataAccess=VCLib.T_DATA_ACCESS.DataAccessID
inner join VCLib.T_ENTITIES on VCLib.T_DATA_ACCESS.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_ITEM
from VCLib.T_EXPORT_ITEM
inner join VCLib.T_EXPORT_TABLE on VCLib.T_EXPORT_ITEM.ExportTable=VCLib.T_EXPORT_TABLE.ExportTableID
inner join VCLib.T_ENTITIES on VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_COLUMN
from VCLib.T_EXPORT_COLUMN
inner join VCLib.T_EXPORT_TABLE on VCLib.T_EXPORT_COLUMN.ExportTable=VCLib.T_EXPORT_TABLE.ExportTableID
inner join VCLib.T_ENTITIES on VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_EXTENSION_ADDATTRIBUTE
from VCLib.T_DATAFORM_EXTENSION_ADDATTRIBUTE
inner join VCLib.T_DATAFORM_EXTENSION on VCLib.T_DATAFORM_EXTENSION_ADDATTRIBUTE.DataformExtension=VCLib.T_DATAFORM_EXTENSION.DataformExtensionID
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_EXTENSION_ROLE
from VCLib.T_DATAFORM_EXTENSION_ROLE
inner join VCLib.T_DATAFORM_EXTENSION on VCLib.T_DATAFORM_EXTENSION_ROLE.DataformExtension=VCLib.T_DATAFORM_EXTENSION.DataformExtensionID
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM
from VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM
inner join VCLib.T_OBJECT_MODIFICATION_ACTION on VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM.ObjectModificationAction=VCLib.T_OBJECT_MODIFICATION_ACTION.ObjectModificationActionID
inner join VCLib.T_ENTITIES on VCLib.T_OBJECT_MODIFICATION_ACTION.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_OBJECT_MODIFICATION_ACTION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_IMPORTLOGITEM
from VCLib.T_IMPORTLOGITEM
inner join VCLib.T_IMPORTLOG on VCLib.T_IMPORTLOGITEM.ImportLogID=VCLib.T_IMPORTLOG.ImportLogID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM
from VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM
inner join VCLib.T_OBJECT_MODIFICATION_ACTION on VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM.ObjectModificationAction=VCLib.T_OBJECT_MODIFICATION_ACTION.ObjectModificationActionID
inner join VCLib.T_ENTITIES on VCLib.T_OBJECT_MODIFICATION_ACTION.Entities=VCLib.T_ENTITIES.EntityID or VCLib.T_OBJECT_MODIFICATION_ACTION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_TEMPLATE_FIELD_VALUE
from VCLib.T_TEMPLATE_FIELD_VALUE
inner join VCLib.T_TEMPLATE_FIELD on VCLib.T_TEMPLATE_FIELD_VALUE.TemplateField=VCLib.T_TEMPLATE_FIELD.TemplateFieldID
inner join VCLib.T_ENTITIES on VCLib.T_TEMPLATE_FIELD.Entity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITIES_ATTRIBUTES
from VCLib.T_ENTITIES_ATTRIBUTES
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_IMPORTLOG
from VCLib.T_IMPORTLOG
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITY_ACCESS_ENTRY
from VCLib.T_ENTITY_ACCESS_ENTRY
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENT_ATTR_ACCESS_ENTRY
from VCLib.T_ENT_ATTR_ACCESS_ENTRY
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_OBJECT_COPY_TEMPLATE
from VCLib.T_OBJECT_COPY_TEMPLATE
inner join VCLib.T_ENTITIES on VCLib.T_OBJECT_COPY_TEMPLATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_TEMPLATE_FIELD
from VCLib.T_TEMPLATE_FIELD
inner join VCLib.T_ENTITIES on VCLib.T_TEMPLATE_FIELD.Entity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_OBJECT_MODIFICATION_ACTION
from VCLib.T_OBJECT_MODIFICATION_ACTION
inner join VCLib.T_ENTITIES on VCLib.T_OBJECT_MODIFICATION_ACTION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXPORT_TABLE
from VCLib.T_EXPORT_TABLE
inner join VCLib.T_ENTITIES on VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_TEMPLATE
from VCLib.T_DATAFORM_TEMPLATE
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_TEMPLATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_CASCADE_DELETE_SETTING
from VCLib.T_CASCADE_DELETE_SETTING
inner join VCLib.T_ENTITIES on VCLib.T_CASCADE_DELETE_SETTING.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_OBJECT_MODIFICATION_ACTION
from VCLib.T_OBJECT_MODIFICATION_ACTION
inner join VCLib.T_ENTITIES on VCLib.T_OBJECT_MODIFICATION_ACTION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_EXTENSION
from VCLib.T_DATAFORM_EXTENSION
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_CLIENT_MODULE_FORM
from VCLib.T_CLIENT_MODULE_FORM
inner join VCLib.T_ENTITIES on VCLib.T_CLIENT_MODULE_FORM.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_SCHEDULER_OPERATION
from VCLib.T_SCHEDULER_OPERATION
inner join VCLib.T_ENTITIES on VCLib.T_SCHEDULER_OPERATION.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATA_ACCESS
from VCLib.T_DATA_ACCESS
inner join VCLib.T_ENTITIES on VCLib.T_DATA_ACCESS.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_CLIENT_MODULE_FEATURE
from VCLib.T_CLIENT_MODULE_FEATURE
inner join VCLib.T_ENTITIES on VCLib.T_CLIENT_MODULE_FEATURE.EntityIndex=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_BASE_FEATURE_SETTINGS
from VCLib.T_BASE_FEATURE_SETTINGS
inner join VCLib.T_ENTITIES on VCLib.T_BASE_FEATURE_SETTINGS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USERS
from VCLib.T_USERS
inner join VCLib.T_ENTITIES on VCLib.T_USERS.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_BASE_ACCESS_ENTRY
from VCLib.T_BASE_ACCESS_ENTRY
inner join VCLib.T_ENTITIES on VCLib.T_BASE_ACCESS_ENTRY.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ADDING_DOCUMENT
from VCLib.T_ADDING_DOCUMENT
inner join VCLib.T_ENTITIES on VCLib.T_ADDING_DOCUMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DATAFORM_VALIDATION
from VCLib.T_DATAFORM_VALIDATION
inner join VCLib.T_ENTITIES on VCLib.T_DATAFORM_VALIDATION.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_TEMPLATE_OVERRIDE
from VCLib.T_TEMPLATE_OVERRIDE
inner join VCLib.T_ENTITIES on VCLib.T_TEMPLATE_OVERRIDE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITIES_WEB_ALIAS
from VCLib.T_ENTITIES_WEB_ALIAS
inner join VCLib.T_ENTITIES on VCLib.T_ENTITIES_WEB_ALIAS.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DTO_MODEL
from VCLib.T_DTO_MODEL
inner join VCLib.T_ENTITIES on VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_Report
from VCLib.T_Report
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_TYPE
from VCLib.T_NOTIFY_MESSAGE_TYPE
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_OBJECT
from VCLib.T_NOTIFY_MESSAGE_OBJECT
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_OBJECT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_LEXEM_PARAMETER
from VCLib.T_LEXEM_PARAMETER
inner join VCLib.T_ENTITIES on VCLib.T_LEXEM_PARAMETER.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_NOTIFY_MESSAGE_TYPE
from VCLib.T_NOTIFY_MESSAGE_TYPE
inner join VCLib.T_ENTITIES on VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_UNITED_OBJECT_CHANGESET
from VCLib.T_UNITED_OBJECT_CHANGESET
inner join VCLib.T_ENTITIES on VCLib.T_UNITED_OBJECT_CHANGESET.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_BaseReport
from VCLib.T_BaseReport
inner join VCLib.T_ENTITIES on VCLib.T_BaseReport.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_REPORT_MENU_ITEM
from VCLib.T_REPORT_MENU_ITEM
inner join VCLib.T_ENTITIES on VCLib.T_REPORT_MENU_ITEM.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DELETED_OBJECT
from VCLib.T_DELETED_OBJECT
inner join VCLib.T_ENTITIES on VCLib.T_DELETED_OBJECT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DELETED_OBJECT_INFO
from VCLib.T_DELETED_OBJECT_INFO
inner join VCLib.T_ENTITIES on VCLib.T_DELETED_OBJECT_INFO.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_UNITED_OBJECT
from VCLib.T_UNITED_OBJECT
inner join VCLib.T_ENTITIES on VCLib.T_UNITED_OBJECT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_CONTEXTS
from VCLib.T_USER_CONTEXTS
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_USER_SEARCHES
from VCLib.T_USER_SEARCHES
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EMAIL_ATTACHMENT
from VCLib.T_EMAIL_ATTACHMENT
inner join VCLib.T_ENTITIES on VCLib.T_EMAIL_ATTACHMENT.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_MAIN
from VCLib.T_GENERIC_REPORT_MAIN
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_MAIN.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GENERATOR
from VCLib.T_GENERIC_REPORT_GENERATOR
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_PROCESS_ACCESS_ENTRY
from VCLib.T_PROCESS_ACCESS_ENTRY
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GROUP
from VCLib.T_GENERIC_REPORT_GROUP
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GROUP.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT_GENERATOR
from VCLib.T_GENERIC_REPORT_GENERATOR
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT_GENERATOR.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_GENERIC_REPORT
from VCLib.T_GENERIC_REPORT
inner join VCLib.T_ENTITIES on VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_COMMAND
from VCLib.T_EXTRA_UI_COMMAND
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_FILE
from VCLib.T_FILE
inner join VCLib.T_ENTITIES on VCLib.T_FILE.type_=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_DICTIONARY_UPDATE
from VCLib.T_DICTIONARY_UPDATE
inner join VCLib.T_ENTITIES on VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_EXTRA_UI_COMMAND
from VCLib.T_EXTRA_UI_COMMAND
inner join VCLib.T_ENTITIES on VCLib.T_EXTRA_UI_COMMAND.CommandEntity=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_HIDDEN_ATTRIBUTE
from VCLib.T_HIDDEN_ATTRIBUTE
inner join VCLib.T_ENTITIES on VCLib.T_HIDDEN_ATTRIBUTE.Entities=VCLib.T_ENTITIES.EntityID
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
 
delete from VCLib.T_ENTITIES
where EntityID = (select EntityID from VCLib.T_ENTITIES e where e.EntName = @entName);
