#####################################################
# Save script as Deploy_SQL.bat
# sql deployment script can be updated to include all .sql .trg files etc
# script installs multiple db objects against target db
# also logs progress & errors to a Deploymentlog.txt file
#####################################################
@Echo off
setlocal enabledelayedexpansion
pause
SET Server=%1
SET DB=%2
pause
SET workdir=%3
IF "x"%workdir%=="x"
SET workdir=%cd%
SET curdir=%cd%
cd %workdir%
pause
for /F %%x IN ('DIR /B *.prc') do (
echo Installing %workdir%\%%x ...
echo Installing %workdir%\%%x ... >> %curDir%\Deploymentlog.txt
SQLCMD -b -E -S %Server% -d %DB% -i%workdir%\%%x >> %curDir%\Deploymentlog.txt
IF !ERRORLEVEL!==1
(
ECHO Error installing %workdir%\%%x . Please refer log file for further details.
ECHO Error installing %workdir%\%%x >> %curDir%\Deploymentlog.txt
GOTO ENDPRO
)
ECHO %workdir%\%%x Completed
ECHO %workdir%\%%x Completed >> %curDir%\Deploymentlog.txt
)
:ENDPRO
cd %curdir%
pause
#end of first script
#####################################################
# to execute
# c:
# cd C:\Databases\Release
# Deploy_SQL SRV1 MY_DB C:\Databases\Release
#####################################################
No comments:
Post a Comment