Guest User

Untitled

a guest
Mar 11th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. :: Name: sql_execute.cmd
  2. :: Purpose: execute script.sql via sqlcmd
  3. :: Author: ettingshausen
  4. :: Revision: 2018/3/1 - initial version
  5. ::
  6.  
  7. @ECHO OFF
  8. SETLOCAL ENABLEEXTENSIONS
  9. SET parent=%~dp0
  10. SET interactive=0
  11. SET sql_script="%parent%%1"
  12. ECHO %COMSPEC% | FINDSTR /L %CMDCMDLINE% >NUL 2>&1
  13. IF %ERRORLEVEL% == 0 SET interactive=1
  14.  
  15.  
  16. SET server="localhost"
  17. SET username="sa"
  18. SET password="root"
  19.  
  20.  
  21. :: execute script
  22. sqlcmd -S %server% -U %username% -P %password% -i %sql_script%
  23.  
  24. IF "%interactive%"=="0" PAUSE
  25. EXIT /B %ERRORLEVEL%
Add Comment
Please, Sign In to add comment