SqlPackage.exe

SqlPackage.exe

可以在visual studio的安装路径下找到,C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\SqlPackage.exe

SqlPackage.exe is a command-line utility that automates the following database development tasks by exposing some of the public Data-Tier Application Framework (DacFx) APIs:

  • Version: Returns the build number of the SqlPackage application. Added in version 18.6.

  • Extract: Creates a data-tier application (.dacpac) file containing the schema or schema and user data from a connected SQL database.

  • Publish: Incrementally updates a database schema to match the schema of a source .dacpac file. If the database does not exist on the server, the publish operation creates it. Otherwise, an existing database is updated.

  • Export: Exports a connected SQL database - including database schema and user data - to a BACPAC file (.bacpac).

  • Import: Imports the schema and table data from a BACPAC file into a new user database.

  • DeployReport: Creates an XML report of the changes that would be made by a publish action.

  • DriftReport: Creates an XML report of the changes that have been made to a registered database since it was last registered.

  • Script: Creates a Transact-SQL incremental update script that updates the schema of a target to match the schema of a source.

The SqlPackage.exe command line tool allows you to specify these actions along with action-specific parameters and properties.

Download the latest version. For details about the latest release, see the release notes.

 

Command-Line Syntax

SqlPackage.exe initiates the actions specified using the parameters, properties, and SQLCMD variables specified on the command line.

cmd
SqlPackage {parameters}{properties}{SQLCMD Variables}  

Usage examples

Further examples are available on the individual action pages.

Generate a comparison between databases by using .dacpac files with a SQL script output

Start by creating a .dacpac file of your latest database changes:

cmd
sqlpackage.exe /TargetFile:"C:\sqlpackageoutput\output_current_version.dacpac" /Action:Extract /SourceServerName:"." /SourceDatabaseName:"Contoso.Database"

Create a .dacpac file of your database target (that has no changes):

cmd
sqlpackage.exe /TargetFile:"C:\sqlpackageoutput\output_target.dacpac" /Action:Extract /SourceServerName:"." /SourceDatabaseName:"Contoso.Database"

Create a SQL script that generates the differences of two .dacpac files:

cmd
sqlpackage.exe /Action:Script /SourceFile:"C:\sqlpackageoutput\output_current_version.dacpac" /TargetFile:"C:\sqlpackageoutput\output_target.dacpac" /TargetDatabaseName:"Contoso.Database" /OutputPath:"C:\sqlpackageoutput\output.sql"

Support

The DacFx library and the SqlPackage CLI tool have adopted the Microsoft Modern Lifecycle Policy. All security updates, fixes, and new features will be released only in the latest point version of the major version. Maintaining your DacFx or SqlPackage installations to the current version helps ensure that you will receive all applicable bug fixes in a timely manner.

Supported SQL offerings

SqlPackage and DacFx supports all supported SQL versions at time of the SqlPackage/DacFx release. For example, a SqlPackage release on January 14th 2022 supports all supported versions of SQL in January 14th 2022. For more on SQL support policies, see the SQL support policy.

Version

Displays the sqlpackage version as a build number. Can be used in interactive prompts as well as in automated pipelines.

cmd
sqlpackage.exe /Version

Help

You can display SqlPackage usage information by using /? or /help:True.

cmd
sqlpackage.exe /?

For parameter and property information specific to a particular action, use the help parameter in addition to that action's parameter.

cmd
sqlpackage.exe /Action:Publish /?

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(88)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2021-08-12 Microsoft.Bcl.Build.targets" cannot be imported again
2021-08-12 Advanced Basics: Using Task Runner in Visual Studio 2019
2019-08-12 HearthBuddy炉石兄弟 如何调试ai
2019-08-12 How to get full path of StreamWriter
2019-08-12 No suitable constructor was found in NUnit Parameterised tests
2015-08-12 Duplex Service in WCF(CodeProject上的)
2015-08-12 wcf双工通讯遇到的问题
点击右上角即可分享
微信分享提示