azure-sql-databasesqlpackage

How to upload (import) with overwrite azure database using sqlpackage.exe


It should be a simple thing to do, I want to upload/import my database with overwrite option, but I can't find it in the documentation

I have to delete it manually and upload with Import.


Solution

  • Ok I found the solution:

    Generate backup:

    C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe"
       /a:Export /ssn:"windowsusername\sqlexpress" /sdn:yourdbname /tf:yourdbname.bacpac
    

    Drop existing database using sqlcmd:

    sqlcmd -U dbusernameonazure@azureservename.database.windows.net
       -P yourpassword -S azureservename.database.windows.net -Q "drop DATABASE yourdbname"
    

    Import database:

    C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe"
       /a:Import /SourceFile:yourdbname.bacpac
       /tsn:azureservename.database.windows.net,1433
       /tdn:yourdbname /tu:dbusernameonazure /tp:yopurpassword