IF EXISTS (SELECT * FROM information_schema.tables WHERE table_schema = 'IES' AND table_name = 'T_INTEGRATION_QUEUE')
BEGIN
ALTER TABLE IES.T_INTEGRATION_QUEUE DROP CONSTRAINT IF EXISTS FK_T_LOAD_SETTINGS_T_INTEGRATION_QUEUE_LoadSettings;
END

ALTER TABLE IES.T_INTEGRATION_QUEUE ADD CONSTRAINT FK_T_LOAD_SETTINGS_T_INTEGRATION_QUEUE_LoadSettings
FOREIGN KEY(LoadSettings) REFERENCES FNS.T_LOAD_SETTINGS(LoadSettingsID);

ALTER TABLE IES.T_INTEGRATION_QUEUE VALIDATE CONSTRAINT FK_T_LOAD_SETTINGS_T_INTEGRATION_QUEUE_LoadSettings;

DROP TABLE IES.T_LOAD_SETTINGS_PATTERNS;
DROP TABLE IES.T_FILE_PATTERN;
DROP TABLE IES.T_VERIFICATION_PATTERN;
DROP TABLE IES.T_LOAD_SETTINGS;