Last active
August 29, 2015 14:07
-
-
Save GoEddie/b1367a663c03f298882a to your computer and use it in GitHub Desktop.
use sqlpackager to deploy ssdt dacpac's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET PATH=C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin;%PATH% | |
SET SourceDacpac=%1 | |
SET Server=%2 | |
SET Database=%3 | |
SET DBUser=%4 | |
SET DBPass=%5 | |
SET SqlDeployScript=%6 | |
SET Variables=%7 | |
SET PublishProfile=%8 | |
STE LastAction= | |
REM If the db doesn't exist then create it | |
SET LastAction=checking db exists | |
sqlcmd -U %DBUser% -P %DBPass% -S %Server% -Q "IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = '%Database%') CREATE DATABASE %Database%" -b | |
if errorlevel 1 goto err | |
REM Save deployment script | |
SET LastAction=deploying updates | |
sqlpackage.exe /action:Publish /sourcefile:%SourceDacpac% /targetservername:%Server% /targetdatabasename:%Database% /targetuser:%DBUser% /targetpassword:%DBPass% /pr:"%PublishProfile%" %Variables% | |
if errorlevel 1 goto err | |
goto success | |
:err | |
echo error occured at %LastAction% - deploy has failed | |
exit 1 | |
:success | |
echo finished |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment