Last active
May 19, 2022 18:04
-
-
Save ettingshausen/9729e2e0be33beb158ff976d0458003c to your computer and use it in GitHub Desktop.
execute sql script via sqlcmd
This file contains 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
:: Name: sql_execute.cmd | |
:: Purpose: execute script.sql via sqlcmd | |
:: Author: ettingshausen | |
:: Revision: 2018/3/1 - initial version | |
:: | |
@ECHO OFF | |
SETLOCAL ENABLEEXTENSIONS | |
SET parent=%~dp0 | |
SET interactive=0 | |
SET sql_script="%parent%%1" | |
ECHO %COMSPEC% | FINDSTR /L %CMDCMDLINE% >NUL 2>&1 | |
IF %ERRORLEVEL% == 0 SET interactive=1 | |
SET server="localhost" | |
SET username="sa" | |
SET password="root" | |
:: execute script | |
sqlcmd -S %server% -U %username% -P %password% -i %sql_script% | |
IF "%interactive%"=="0" PAUSE | |
EXIT /B %ERRORLEVEL% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment