目标数据库是Azure数据库时,如何使用SqlPackage命令行方法摆脱USE语句?
执行时:
SqlPackage /a:script [...]
我总是得到:
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)];
执行此脚本时:
sqlcmd -S [...] $pathToUpdateScript
我收到此错误消息:
USE statement is not supported to switch between databases. Use a new connection to connect to a different database.
那么,如何从USE
生成的脚本中删除SqlPackage /a:script
语句?有没有一种方法可以使用任何命令行参数来支持此操作?