如何执行SqlPackage命令行以生成没有USE语句的脚本

时间:2019-07-04 08:07:58

标签: sql-server database azure azure-sql-database sqlpackage

目标数据库是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语句?有没有一种方法可以使用任何命令行参数来支持此操作?

0 个答案:

没有答案