SSDT SQL Server数据库项目中的模式比较的命令行/ API? [英] Command-line/API for Schema Compare in SSDT SQL Server Database Project?
问题描述
在Visual Studio 2012中,我们有 模式比较
在 SSDT 的 SQL Server数据库项目
(DbProject)项目帮助
In Visual Studio 2012, we have Schema Compare
in SSDT's SQL Server Database Project
(DbProject) project which helps
- 比较
源
与目标
- 更新
目标
以使其与源
相同
- Compare
source
versustarget
- Update
target
to make it the same assource
其中
- 源和目标可以是数据库,DbProject项目或.dacpac文件
- 更新可以通过更新操作或生成的脚本
- Source and target can be either a database, a DbProject project, or a .dacpac file
- Update can be done via an update action or generated script
我的问题是,是否可以有和在哪里可以获得命令行/ API接口来调用此功能?
My question is that is it possible to have and where can I get the command-line/API interface to call this feature?
推荐答案
p> SOURCE数据库
sqlpackage.exe / a:Extract / scs:Server =%Server%; Database = AspBaselineDB; /tf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac
SOURCE Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=AspBaselineDB; /tf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac
TARGET数据库
sqlpackage.exe / a:Extract / scs:Server =%Server%; Database =%AspTargetDB-2%; /tf:%DriveSpec%\%DacPath%\%AspTargetDB%.dacpac
TARGET Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=%AspTargetDB-2%; /tf:%DriveSpec%\%DacPath%\%AspTargetDB%.dacpac
COMPARE&生成Delta脚本
sqlpackage.exe / a:Script /sf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac
/ tf:%DriveSpec%\ %DacPath%\AspNetDb\%AspTargetDB%.dacpac / tdn:aspTargetdb /op:%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
COMPARE & GENERATE the Delta script sqlpackage.exe /a:Script /sf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac /tf:%DriveSpec%\%DacPath%\AspNetDb\%AspTargetDB%.dacpac /tdn:aspTargetdb /op:%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
EXECUTE脚本
sqlcmd.exe -S%Server%\aspnetdbAmexDev -i%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
EXECUTE the script sqlcmd.exe -S %Server%\aspnetdbAmexDev -i %DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
我在CMD脚本中这样做,因为我们的IT部门不会允许未签名的PowerShell脚本,他们不会购买证书。即使从TFS 2012 Team Builds调用它,或者只是以管理员身份从VS命令提示符处执行.CMD脚本,它也能正常工作。
I do this in CMD scripting as our IT dept will not allow unsigned PowerShell scripts and they won't purchase a cert. This works flawlessly, even when calling it from TFS 2012 Team Builds or simply executing the .CMD script from a VS command prompt as Administrator.
strong>
Note!
在脚本中添加以下SET:SET PATH =%PATH%; C:\Program Files(x86)\ Microsoft SQL Server \110\\ \\ DAC \bin
Add the following SET in your script: SET PATH=%PATH%;C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin
还有:你可以看到我设置路径变量。我这样做,因为我接触了50种风格的数据库,这是唯一一致的方式,我发现生成增量脚本和更新我们的DEV和TEST数据库。
Also: as you can see I set path variables. I do this as I am touching up to 50 flavors of the database and this is the only consistent way I have found to generate delta scripts and update our DEV and TEST databases.
这篇关于SSDT SQL Server数据库项目中的模式比较的命令行/ API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!