Unable to restore bacpac due to foreign key conflict

前端 未结 1 544
Happy的楠姐
Happy的楠姐 2021-02-13 12:41

I\'m attempting to restore a backup (.bacpac) of a SQL Azure database to another SQL Azure database but am unable to do so because of the following error:

1条回答
  •  一向
    一向 (楼主)
    2021-02-13 13:21

    The bacpac file is not transactional, so new rows written to your target database while the bacpac is being generated will end up corrupting the index. The database either must have no other users connected making writes, or you can copy the database and make a bacpac from the copy.

    1) Copy the target database, which will return straight away, but the database will take some time to copy. This operation will create a full transactional copy:

    CREATE DATABASE  AS COPY OF 
    

    2) Find the status of your copy operation:

    SELECT * FROM sys.dm_database_copies
    

    3) Generate a bacpac file on the copied database, which isn't being used by anyone.

    4) Delete the copied database, and you'll have a working bacpac file.

    0 讨论(0)
提交回复
热议问题