-- generator on mysql

select 
    concat(
        'set identity_insert [', 
        c.TABLE_NAME, 
        '] on\nGO\n\n',

        'insert into [',
        c.TABLE_NAME,
        '] (',
        group_concat(concat('[', c.COLUMN_NAME, ']') order by c.ORDINAL_POSITION separator ', '),
        ') select ',
        group_concat(concat('[', c.COLUMN_NAME, ']') order by c.ORDINAL_POSITION separator ', '),
        ' from openquery(CARLEYF, \'select * from ',
        c.TABLE_NAME, 
        '\');\nGO\n\n',

        'set identity_insert [', 
        c.TABLE_NAME, 
        '] off\nGO\n\n'
    )
from INFORMATION_SCHEMA.COLUMNS c
where c.TABLE_SCHEMA = 'prj_carleyfoundry_import'
group by c.TABLE_SCHEMA, c.TABLE_NAME



-- generated on mssql
/*
set identity_insert [cf_AclResource] on
GO

insert into [cf_AclResource] ([id], [title], [query], [message], [sorter], [added], [changed]) select [id], [title], [query], [message], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_AclResource');
GO

set identity_insert [cf_AclResource] off
GO


set identity_insert [cf_AclResource2Role] on
GO

insert into [cf_AclResource2Role] ([idAclResource], [idAclRole]) select [idAclResource], [idAclRole] from openquery(CARLEYF, 'select * from cf_AclResource2Role');
GO

set identity_insert [cf_AclResource2Role] off
GO


set identity_insert [cf_AclResourcePrivilege] on
GO

insert into [cf_AclResourcePrivilege] ([idAclResource], [name], [title], [sorter]) select [idAclResource], [name], [title], [sorter] from openquery(CARLEYF, 'select * from cf_AclResourcePrivilege');
GO

set identity_insert [cf_AclResourcePrivilege] off
GO


set identity_insert [cf_AclRole] on
GO

insert into [cf_AclRole] ([id], [title], [added], [changed]) select [id], [title], [added], [changed] from openquery(CARLEYF, 'select * from cf_AclRole');
GO

set identity_insert [cf_AclRole] off
GO


set identity_insert [cf_AclRule] on
GO

insert into [cf_AclRule] ([id], [idAclRole], [idRole], [idAclResource], [privilege], [type], [sorter], [added], [changed]) select [id], [idAclRole], [idRole], [idAclResource], [privilege], [type], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_AclRule');
GO

set identity_insert [cf_AclRule] off
GO


set identity_insert [cf_Client] on
GO

insert into [cf_Client] ([id], [number], [name], [added], [changed]) select [id], [number], [name], [added], [changed] from openquery(CARLEYF, 'select * from cf_Client');
GO

set identity_insert [cf_Client] off
GO


set identity_insert [cf_Client2User] on
GO

insert into [cf_Client2User] ([id], [clientId], [userId]) select [id], [clientId], [userId] from openquery(CARLEYF, 'select * from cf_Client2User');
GO

set identity_insert [cf_Client2User] off
GO


set identity_insert [cf_Department] on
GO

insert into [cf_Department] ([id], [parentId], [name], [sorter], [added], [changed]) select [id], [parentId], [name], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_Department');
GO

set identity_insert [cf_Department] off
GO


set identity_insert [cf_DepartmentAndProcessSorter] on
GO

insert into [cf_DepartmentAndProcessSorter] ([id], [departmentId], [processId], [sorter]) select [id], [departmentId], [processId], [sorter] from openquery(CARLEYF, 'select * from cf_DepartmentAndProcessSorter');
GO

set identity_insert [cf_DepartmentAndProcessSorter] off
GO


set identity_insert [cf_DPermission] on
GO

insert into [cf_DPermission] ([id], [title], [resourceId], [privilegeId]) select [id], [title], [resourceId], [privilegeId] from openquery(CARLEYF, 'select * from cf_DPermission');
GO

set identity_insert [cf_DPermission] off
GO


set identity_insert [cf_DPrivilege] on
GO

insert into [cf_DPrivilege] ([id], [name]) select [id], [name] from openquery(CARLEYF, 'select * from cf_DPrivilege');
GO

set identity_insert [cf_DPrivilege] off
GO


set identity_insert [cf_DResource] on
GO

insert into [cf_DResource] ([id], [name]) select [id], [name] from openquery(CARLEYF, 'select * from cf_DResource');
GO

set identity_insert [cf_DResource] off
GO


set identity_insert [cf_DState] on
GO

insert into [cf_DState] ([id], [title]) select [id], [title] from openquery(CARLEYF, 'select * from cf_DState');
GO

set identity_insert [cf_DState] off
GO


set identity_insert [cf_DStatus] on
GO

insert into [cf_DStatus] ([id], [title]) select [id], [title] from openquery(CARLEYF, 'select * from cf_DStatus');
GO

set identity_insert [cf_DStatus] off
GO


set identity_insert [cf_Form] on
GO

insert into [cf_Form] ([id], [blockedBy], [blockedAt], [height], [added], [changed]) select [id], [blockedBy], [blockedAt], [height], [added], [changed] from openquery(CARLEYF, 'select * from cf_Form');
GO

set identity_insert [cf_Form] off
GO


set identity_insert [cf_FormElement] on
GO

insert into [cf_FormElement] ([id], [formId], [formType], [typeId], [left], [top], [zIndex], [draftFor], [added], [changed]) select [id], [formId], [formType], [typeId], [left], [top], [zIndex], [draftFor], [added], [changed] from openquery(CARLEYF, 'select * from cf_FormElement');
GO

set identity_insert [cf_FormElement] off
GO


set identity_insert [cf_FormElementProperty] on
GO

insert into [cf_FormElementProperty] ([id], [elementTypeId], [label], [alias], [type], [options], [sorter]) select [id], [elementTypeId], [label], [alias], [type], [options], [sorter] from openquery(CARLEYF, 'select * from cf_FormElementProperty');
GO

set identity_insert [cf_FormElementProperty] off
GO


set identity_insert [cf_FormElementPropertyValue] on
GO

insert into [cf_FormElementPropertyValue] ([elementId], [propertyId], [value]) select [elementId], [propertyId], [value] from openquery(CARLEYF, 'select * from cf_FormElementPropertyValue');
GO

set identity_insert [cf_FormElementPropertyValue] off
GO


set identity_insert [cf_FormSubmission] on
GO

insert into [cf_FormSubmission] ([id], [formId], [formType], [added], [changed]) select [id], [formId], [formType], [added], [changed] from openquery(CARLEYF, 'select * from cf_FormSubmission');
GO

set identity_insert [cf_FormSubmission] off
GO


set identity_insert [cf_FormSubmissionValue] on
GO

insert into [cf_FormSubmissionValue] ([id], [submissionId], [elementId], [value]) select [id], [submissionId], [elementId], [value] from openquery(CARLEYF, 'select * from cf_FormSubmissionValue');
GO

set identity_insert [cf_FormSubmissionValue] off
GO


set identity_insert [cf_Media] on
GO

insert into [cf_Media] ([id], [processId], [partId], [revisionStart], [revisionEnd], [title], [description], [type], [image], [video], [sorter], [added], [changed]) select [id], [processId], [partId], [revisionStart], [revisionEnd], [title], [description], [type], [image], [video], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_Media');
GO

set identity_insert [cf_Media] off
GO


set identity_insert [cf_Part] on
GO

insert into [cf_Part] ([id], [blockedVersion], [blockedBy], [blockedAt], [height], [defaultProcessId], [currentVersion], [sorter], [added], [changed]) select [id], [blockedVersion], [blockedBy], [blockedAt], [height], [defaultProcessId], [currentVersion], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_Part');
GO

set identity_insert [cf_Part] off
GO


set identity_insert [cf_Part2PartData] on
GO

insert into [cf_Part2PartData] ([id], [partId], [versionId], [added], [changed]) select [id], [partId], [versionId], [added], [changed] from openquery(CARLEYF, 'select * from cf_Part2PartData');
GO

set identity_insert [cf_Part2PartData] off
GO


set identity_insert [cf_Part2Process] on
GO

insert into [cf_Part2Process] ([partId], [processId]) select [partId], [processId] from openquery(CARLEYF, 'select * from cf_Part2Process');
GO

set identity_insert [cf_Part2Process] off
GO


set identity_insert [cf_Part2ProcessData] on
GO

insert into [cf_Part2ProcessData] ([id], [processId], [versionId], [setId], [revisionEnd], [added], [changed]) select [id], [processId], [versionId], [setId], [revisionEnd], [added], [changed] from openquery(CARLEYF, 'select * from cf_Part2ProcessData');
GO

set identity_insert [cf_Part2ProcessData] off
GO


set identity_insert [cf_Part2User] on
GO

insert into [cf_Part2User] ([id], [partId], [userId]) select [id], [partId], [userId] from openquery(CARLEYF, 'select * from cf_Part2User');
GO

set identity_insert [cf_Part2User] off
GO


set identity_insert [cf_PartVersion] on
GO

insert into [cf_PartVersion] ([id], [partId], [preProduction], [version], [number], [name], [clientId], [weight], [alloyTemper], [status], [localDirectory], [image], [comments], [userId], [added], [changed]) select [id], [partId], [preProduction], [version], [number], [name], [clientId], [weight], [alloyTemper], [status], [localDirectory], [image], [comments], [userId], [added], [changed] from openquery(CARLEYF, 'select * from cf_PartVersion');
GO

set identity_insert [cf_PartVersion] off
GO


set identity_insert [cf_Process] on
GO

insert into [cf_Process] ([id], [departmentId], [name], [isMedia], [isMultiply], [sorter], [blockedBy], [blockedAt], [height], [sidebar], [new], [added], [changed]) select [id], [departmentId], [name], [isMedia], [isMultiply], [sorter], [blockedBy], [blockedAt], [height], [sidebar], [new], [added], [changed] from openquery(CARLEYF, 'select * from cf_Process');
GO

set identity_insert [cf_Process] off
GO


set identity_insert [cf_Process2User] on
GO

insert into [cf_Process2User] ([id], [processId], [userId]) select [id], [processId], [userId] from openquery(CARLEYF, 'select * from cf_Process2User');
GO

set identity_insert [cf_Process2User] off
GO


set identity_insert [cf_User] on
GO

insert into [cf_User] ([id], [firstName], [lastName], [login], [email], [password], [salt], [autologinCode], [newPassword], [newSalt], [recoverCode], [recoverCodeExpirationDate], [added], [changed]) select [id], [firstName], [lastName], [login], [email], [password], [salt], [autologinCode], [newPassword], [newSalt], [recoverCode], [recoverCodeExpirationDate], [added], [changed] from openquery(CARLEYF, 'select * from cf_User');
GO

set identity_insert [cf_User] off
GO


set identity_insert [cf_User2Department] on
GO

insert into [cf_User2Department] ([userId], [departmentId]) select [userId], [departmentId] from openquery(CARLEYF, 'select * from cf_User2Department');
GO

set identity_insert [cf_User2Department] off
GO


set identity_insert [cf_User2Permission] on
GO

insert into [cf_User2Permission] ([userId], [permissionId]) select [userId], [permissionId] from openquery(CARLEYF, 'select * from cf_User2Permission');
GO

set identity_insert [cf_User2Permission] off
GO


set identity_insert [cf_zz_Admin] on
GO

insert into [cf_zz_Admin] ([id], [firstName], [middleInitial], [lastName], [login], [password], [salt], [autologinCode], [remoteAuthEnabled], [remotePasswordExpirationDate], [email], [stsLoginCode], [stsLoginEnabled], [added], [changed]) select [id], [firstName], [middleInitial], [lastName], [login], [password], [salt], [autologinCode], [remoteAuthEnabled], [remotePasswordExpirationDate], [email], [stsLoginCode], [stsLoginEnabled], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_Admin');
GO

set identity_insert [cf_zz_Admin] off
GO


set identity_insert [cf_zz_DFileType] on
GO

insert into [cf_zz_DFileType] ([extension], [type]) select [extension], [type] from openquery(CARLEYF, 'select * from cf_zz_DFileType');
GO

set identity_insert [cf_zz_DFileType] off
GO


set identity_insert [cf_zz_DLanguage] on
GO

insert into [cf_zz_DLanguage] ([name], [title], [shortTitle], [icon], [locale], [def], [enabled], [sorter]) select [name], [title], [shortTitle], [icon], [locale], [def], [enabled], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DLanguage');
GO

set identity_insert [cf_zz_DLanguage] off
GO


set identity_insert [cf_zz_DNotFoundMode] on
GO

insert into [cf_zz_DNotFoundMode] ([id], [title], [sorter]) select [id], [title], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DNotFoundMode');
GO

set identity_insert [cf_zz_DNotFoundMode] off
GO


set identity_insert [cf_zz_DPageHandler] on
GO

insert into [cf_zz_DPageHandler] ([name], [title], [sorter]) select [name], [title], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DPageHandler');
GO

set identity_insert [cf_zz_DPageHandler] off
GO


set identity_insert [cf_zz_DPageItemGroup] on
GO

insert into [cf_zz_DPageItemGroup] ([id], [name], [title], [sorter]) select [id], [name], [title], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DPageItemGroup');
GO

set identity_insert [cf_zz_DPageItemGroup] off
GO


set identity_insert [cf_zz_DPageItemType] on
GO

insert into [cf_zz_DPageItemType] ([id], [type], [title], [sorter]) select [id], [type], [title], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DPageItemType');
GO

set identity_insert [cf_zz_DPageItemType] off
GO


set identity_insert [cf_zz_DPageOption] on
GO

insert into [cf_zz_DPageOption] ([name], [title], [show], [value], [sorter]) select [name], [title], [show], [value], [sorter] from openquery(CARLEYF, 'select * from cf_zz_DPageOption');
GO

set identity_insert [cf_zz_DPageOption] off
GO


set identity_insert [cf_zz_DraftHtmlBlock] on
GO

insert into [cf_zz_DraftHtmlBlock] ([id], [added]) select [id], [added] from openquery(CARLEYF, 'select * from cf_zz_DraftHtmlBlock');
GO

set identity_insert [cf_zz_DraftHtmlBlock] off
GO


set identity_insert [cf_zz_DraftHtmlBlockContent] on
GO

insert into [cf_zz_DraftHtmlBlockContent] ([idBlock], [language], [content], [added], [changed]) select [idBlock], [language], [content], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_DraftHtmlBlockContent');
GO

set identity_insert [cf_zz_DraftHtmlBlockContent] off
GO


set identity_insert [cf_zz_DraftPage] on
GO

insert into [cf_zz_DraftPage] ([id], [idParent], [alias], [handler], [bodyTemplate], [showInSiteMap], [showInMenu], [allowDelete], [isSecure], [isIndexing], [isRoot], [hasBlocks], [final], [system], [redirect], [redirectType], [redirectPageId], [redirectStatus], [redirectAlias], [sorter], [added], [changed]) select [id], [idParent], [alias], [handler], [bodyTemplate], [showInSiteMap], [showInMenu], [allowDelete], [isSecure], [isIndexing], [isRoot], [hasBlocks], [final], [system], [redirect], [redirectType], [redirectPageId], [redirectStatus], [redirectAlias], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_DraftPage');
GO

set identity_insert [cf_zz_DraftPage] off
GO


set identity_insert [cf_zz_DraftPageContent] on
GO

insert into [cf_zz_DraftPageContent] ([idPage], [language], [title], [menuTitle], [header], [keywords], [description]) select [idPage], [language], [title], [menuTitle], [header], [keywords], [description] from openquery(CARLEYF, 'select * from cf_zz_DraftPageContent');
GO

set identity_insert [cf_zz_DraftPageContent] off
GO


set identity_insert [cf_zz_DraftPageItem] on
GO

insert into [cf_zz_DraftPageItem] ([id], [idPage], [idGroup], [type], [number], [name], [title], [allowDelete], [sorter], [added], [changed]) select [id], [idPage], [idGroup], [type], [number], [name], [title], [allowDelete], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_DraftPageItem');
GO

set identity_insert [cf_zz_DraftPageItem] off
GO


set identity_insert [cf_zz_DraftPageItemConfig] on
GO

insert into [cf_zz_DraftPageItemConfig] ([id], [idItem], [name], [value]) select [id], [idItem], [name], [value] from openquery(CARLEYF, 'select * from cf_zz_DraftPageItemConfig');
GO

set identity_insert [cf_zz_DraftPageItemConfig] off
GO


set identity_insert [cf_zz_DraftPageOption] on
GO

insert into [cf_zz_DraftPageOption] ([id], [idPage], [name], [show], [value]) select [id], [idPage], [name], [show], [value] from openquery(CARLEYF, 'select * from cf_zz_DraftPageOption');
GO

set identity_insert [cf_zz_DraftPageOption] off
GO


set identity_insert [cf_zz_File] on
GO

insert into [cf_zz_File] ([id], [name], [nameFs], [type], [size], [added]) select [id], [name], [nameFs], [type], [size], [added] from openquery(CARLEYF, 'select * from cf_zz_File');
GO

set identity_insert [cf_zz_File] off
GO


set identity_insert [cf_zz_HtmlBlock] on
GO

insert into [cf_zz_HtmlBlock] ([id], [added]) select [id], [added] from openquery(CARLEYF, 'select * from cf_zz_HtmlBlock');
GO

set identity_insert [cf_zz_HtmlBlock] off
GO


set identity_insert [cf_zz_HtmlBlockContent] on
GO

insert into [cf_zz_HtmlBlockContent] ([idBlock], [language], [content], [added], [changed]) select [idBlock], [language], [content], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_HtmlBlockContent');
GO

set identity_insert [cf_zz_HtmlBlockContent] off
GO


set identity_insert [cf_zz_Log] on
GO

insert into [cf_zz_Log] ([id], [priority], [ip], [idSession], [serverName], [url], [message], [backtrace], [added]) select [id], [priority], [ip], [idSession], [serverName], [url], [message], [backtrace], [added] from openquery(CARLEYF, 'select * from cf_zz_Log');
GO

set identity_insert [cf_zz_Log] off
GO


set identity_insert [cf_zz_NotFound] on
GO

insert into [cf_zz_NotFound] ([id], [modeId], [isAjax], [request], [referer], [userAgent], [ipAddress], [added]) select [id], [modeId], [isAjax], [request], [referer], [userAgent], [ipAddress], [added] from openquery(CARLEYF, 'select * from cf_zz_NotFound');
GO

set identity_insert [cf_zz_NotFound] off
GO


set identity_insert [cf_zz_Page] on
GO

insert into [cf_zz_Page] ([id], [idParent], [alias], [handler], [bodyTemplate], [showInSiteMap], [showInMenu], [allowDelete], [isSecure], [isIndexing], [isRoot], [hasBlocks], [final], [system], [redirect], [redirectType], [redirectPageId], [redirectStatus], [redirectAlias], [sorter], [added], [changed]) select [id], [idParent], [alias], [handler], [bodyTemplate], [showInSiteMap], [showInMenu], [allowDelete], [isSecure], [isIndexing], [isRoot], [hasBlocks], [final], [system], [redirect], [redirectType], [redirectPageId], [redirectStatus], [redirectAlias], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_Page');
GO

set identity_insert [cf_zz_Page] off
GO


set identity_insert [cf_zz_PageContent] on
GO

insert into [cf_zz_PageContent] ([idPage], [language], [title], [menuTitle], [header], [keywords], [description]) select [idPage], [language], [title], [menuTitle], [header], [keywords], [description] from openquery(CARLEYF, 'select * from cf_zz_PageContent');
GO

set identity_insert [cf_zz_PageContent] off
GO


set identity_insert [cf_zz_PageIndex] on
GO

insert into [cf_zz_PageIndex] ([id], [idPage], [language], [url], [title], [content], [scriptDuration], [reindex], [added], [changed]) select [id], [idPage], [language], [url], [title], [content], [scriptDuration], [reindex], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_PageIndex');
GO

set identity_insert [cf_zz_PageIndex] off
GO


set identity_insert [cf_zz_PageItem] on
GO

insert into [cf_zz_PageItem] ([id], [idPage], [idGroup], [type], [number], [name], [title], [allowDelete], [sorter], [added], [changed]) select [id], [idPage], [idGroup], [type], [number], [name], [title], [allowDelete], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_PageItem');
GO

set identity_insert [cf_zz_PageItem] off
GO


set identity_insert [cf_zz_PageItemConfig] on
GO

insert into [cf_zz_PageItemConfig] ([id], [idItem], [name], [value]) select [id], [idItem], [name], [value] from openquery(CARLEYF, 'select * from cf_zz_PageItemConfig');
GO

set identity_insert [cf_zz_PageItemConfig] off
GO


set identity_insert [cf_zz_PageOption] on
GO

insert into [cf_zz_PageOption] ([id], [idPage], [name], [show], [value]) select [id], [idPage], [name], [show], [value] from openquery(CARLEYF, 'select * from cf_zz_PageOption');
GO

set identity_insert [cf_zz_PageOption] off
GO


set identity_insert [cf_zz_Redirection] on
GO

insert into [cf_zz_Redirection] ([id], [source], [dest], [status], [added], [changed]) select [id], [source], [dest], [status], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_Redirection');
GO

set identity_insert [cf_zz_Redirection] off
GO


set identity_insert [cf_zz_Settings] on
GO

insert into [cf_zz_Settings] ([name], [idCategory], [fieldType], [label], [value], [options], [description], [required], [system], [sorter], [added], [changed]) select [name], [idCategory], [fieldType], [label], [value], [options], [description], [required], [system], [sorter], [added], [changed] from openquery(CARLEYF, 'select * from cf_zz_Settings');
GO

set identity_insert [cf_zz_Settings] off
GO


set identity_insert [cf_zz_SettingsCategory] on
GO

insert into [cf_zz_SettingsCategory] ([id], [name], [system], [sorter]) select [id], [name], [system], [sorter] from openquery(CARLEYF, 'select * from cf_zz_SettingsCategory');
GO

set identity_insert [cf_zz_SettingsCategory] off
GO


set identity_insert [cf_zz_SettingsOptions] on
GO

insert into [cf_zz_SettingsOptions] ([id], [name], [variable], [value], [type]) select [id], [name], [variable], [value], [type] from openquery(CARLEYF, 'select * from cf_zz_SettingsOptions');
GO

set identity_insert [cf_zz_SettingsOptions] off
GO
*/