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

sachin gupta 376 Reputation points
2022-04-13T22:31:58.017+00:00

Hello,

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?

Thanks,
Sachin

Azure SQL Database
Transact-SQL
Transact-SQL
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
    2022-04-13T23:44:38.163+00:00

    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
    2022-04-14T08:40:03.81+00:00

    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,
    LiHong

    0 comments No comments