lundi 23 février 2015

Transaction with multiple SQLCMD calls in a batch file


Is there a good way to do something like the following?



SQLCMD -S %SERVER% -E -Q "BEGIN TRANSACTION"
FOR %%f in (script1 script2 script3) do (
SET CURRENT_SCRIPT=%%f
SQLCMD -S Localhost -E -b -V 1 -i %%f.sql -o %%f.log
IF !ERRORLEVEL! NEQ 0 GOTO ERROR
SET CURRENT_SCRIPT=
)
SQLCMD -S %SERVER% -E -Q "COMMIT TRANSACTION"




Aucun commentaire:

Enregistrer un commentaire