SQLPackage does not delete the tables from Target Database if it does not exist in Source Database

sachin gupta 376 Reputation points


I have 26 tables in my Development database. Using the SQLPackage "Extract" action I am able to generate the DACPAC file and using the "Publish" action deployed in UAT database. All 26 tables deployed successfully in UAT.
Later I deleted 2 tables from Development database and then followed the same steps of extract and publish, but both the tables did not get deleted from UAT database.

I read the Publish action by default will not drop the tables from the target database if not exist is source database. Can anyone guide me how we can achieve this?


Azure SQL Database
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,582 questions
0 comments No comments
{count} vote

Accepted answer
  1. Alberto Morillo 33,251 Reputation points MVP

    Please use the SqlPackage parameter named DropObjectsNotInSource. Please read documentation here. It is a boolean parameter.

    You may want to consider also having BlockOnPossibleDataLoss parameter disabled.

1 additional answer

Sort by: Most helpful
  1. LiHong-MSFT 10,046 Reputation points

    Hi @sachin gupta
    You could specify property DropObjectsNotInSource=(BOOLEAN) to the Publish action.
    Specifies whether objects that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database.
    You can find more information about this utility and SQLPackage actions from the official documentation from Microsoft.

    Best regards,

    0 comments No comments