问题描述
在Visual Studio 2012年,我们有在的 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?
推荐答案
源数据库
sqlpackage.exe / A:提取/ SCS:服务器=%服务器%;数据库= AspBaselineDB; / TF:%DriveSpec%\\%DacPath%\\%AspBaselineDB%_baseline.dacpac
SOURCE Databasesqlpackage.exe /a:Extract /scs:Server=%Server%;Database=AspBaselineDB; /tf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac
目标数据库
sqlpackage.exe / A:提取/ SCS:服务器=%服务器%;数据库=%AspTargetDB-2%; / TF:%DriveSpec%\\%DacPath%\\%AspTargetDB%.dacpac
TARGET Databasesqlpackage.exe /a:Extract /scs:Server=%Server%;Database=%AspTargetDB-2%; /tf:%DriveSpec%\%DacPath%\%AspTargetDB%.dacpac
比较和放大器;生成脚本三角洲
sqlpackage.exe / A:脚本/sf:%DriveSpec%\\%DacPath%\\%AspBaselineDB%_baseline.dacpac
/tf:%DriveSpec%\\%DacPath%\\AspNetDb\\%AspTargetDB%.dacpac / TDN:aspTargetdb / OP:%DriveSpec%\\%SQLPATH%\\ ASPNETDB \\ AspDbUpdate.sql
COMPARE & GENERATE the Delta scriptsqlpackage.exe /a:Script /sf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac /tf:%DriveSpec%\%DacPath%\AspNetDb\%AspTargetDB%.dacpac /tdn:aspTargetdb /op:%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
执行脚本
sqlcmd.exe -S%服务器%\\ aspnetdbAmexDev -i%DriveSpec%\\%SQLPATH%\\ ASPNETDB \\ AspDbUpdate.sql
EXECUTE the scriptsqlcmd.exe -S %Server%\aspnetdbAmexDev -i %DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql
我为此在CMD脚本作为我们的IT部门不会让未签名的PowerShell脚本,他们不会购买证书。从TFS 2012团队调用它,当构建或者干脆从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.
注意!
添加以下设置脚本: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香精这是唯一一致的方式,我发现生成增量脚本和更新我们的开发和测试数据库。
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.
这篇关于命令行/ API的模式SSDT中的SQL Server数据库项目比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!