print 'migrate fns.T_LOAD_SETTINGS' + ' ' + convert(varchar(10), getdate(), 104) + ' ' + convert(varchar(8), getdate(), 114)

declare @LoadSettingsEntityID_IES int = (select top 1 e.EntityID from vclib.T_ENTITIES e where e.EntName = 'LOAD_SETTINGS' and e.[Schema] = 'IES')

delete from FNS.T_LOAD_SETTINGS
insert INTO FNS.T_LOAD_SETTINGS(LoadSettingsID, Name, CreateData, type_) 
SELECT LoadSettingsID, Name, CreateData, @LoadSettingsEntityID_IES
FROM IES.T_LOAD_SETTINGS;

print 'migrate fns.T_VERIFICATION_PATTERN' + ' ' + convert(varchar(10), getdate(), 104) + ' ' + convert(varchar(8), getdate(), 114)

DELETE FROM FNS.T_VERIFICATION_PATTERN 
insert INTO FNS.T_VERIFICATION_PATTERN 
SELECT VerificationPatternID, Name, Descr, Version, IgnoreFileCount, [Procedure], IsBulk, IsAdditional
FROM IES.T_VERIFICATION_PATTERN;

print 'migrate fns.T_FILE_PATTERN' + ' ' + convert(varchar(10), getdate(), 104) + ' ' + convert(varchar(8), getdate(), 114)

DELETE FROM FNS.T_FILE_PATTERN 
insert INTO FNS.T_FILE_PATTERN 
SELECT FilePatternID, VerificationPattern, Pattern, XsdSchema, LoadSchema, [Procedure], Version, IsRequired
FROM IES.T_FILE_PATTERN;

print 'migrate fns.T_LOAD_SETTINGS_PATTERNS' + ' ' + convert(varchar(10), getdate(), 104) + ' ' + convert(varchar(8), getdate(), 114)

DELETE FROM FNS.T_LOAD_SETTINGS_PATTERNS 
insert INTO FNS.T_LOAD_SETTINGS_PATTERNS 
SELECT LoadSettingsPatternsID, LoadSettings, VerificationPattern
FROM IES.T_LOAD_SETTINGS_PATTERNS;
GO