I try to copy a database from 1 server to the other to build a staging environment. I do this with SSID. First I delete the existing database on my staging server, create a new and empty one and then I run the script. I copy everything. Most of my databases copy correctly except for 1 which gives me a Foreign Key constraint error. What can I do to fix this? I tried googling, but without any results.
SSIS package "XXXXXXXX.dtsx" starting.
Information: 0x4002F418 at MyDatabase, Transfer SQL Server Objects Task: There are no Logins to transfer.
Error: 0xC002F325 at myDB, Transfer SQL Server Objects Task: Execution failed with the following error: "ERROR : errorCode=-1073548784 description=Executing the query "ALTER TABLE [dbo].[TemplatePropertyValue] WITH CH..." failed with the following error: "The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_VALUE1_Template". The conflict occurred in database "myDB", table "dbo.Template", column 'Id'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
helpFile= helpContext=0 idofInterfaceWithError={C81DFC5A-3B22-4DA3-BD3B-10BF861A7F9C}".
Task failed: myDB
SSIS package "XXXXXXXXX.dtsx" finished: Success.