How to get rid of the USE statement when using SqlPackage command line method when the target DB is a Azure Database ?
When executing:
SqlPackage /a:script [...]
I always get :
GO
:setvar DatabaseName "databasename"
:setvar DefaultFilePrefix "databasename"
:setvar DefaultDataPath ""
:setvar DefaultLogPath ""
GO
:on error exit
GO
/*
Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
To re-enable the script after enabling SQLCMD mode, execute the following:
SET NOEXEC OFF;
*/
:setvar __IsSqlCmdEnabled "True"
GO
USE [$(DatabaseName)];
And when executing this script :
sqlcmd -S [...] $pathToUpdateScript
I am getting this error message :
USE statement is not supported to switch between databases. Use a new connection to connect to a different database.
So, How do I remove the USE
statement from the script generated by SqlPackage /a:script
? Is there a way to use any command line parameter to support this action ?