Created
July 19, 2017 09:24
-
-
Save Rotceh/4cd594bc81b9659a719720a728418fa7 to your computer and use it in GitHub Desktop.
執行指定目錄內的.sql腳本
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
| @echo off | |
| rem 資料庫IP\資料庫執行個體名稱 | |
| set dbIp=stanley\SQL2014 | |
| rem 資料庫名稱 | |
| set dbName=TSQL2014 | |
| rem 登入帳號 | |
| set dbUsrAcc=ImDeveloper | |
| rem 使用者密碼 | |
| set dbUsrPwd=Passw0rd | |
| rem 整理完畢的SQL指令集資料夾位置 | |
| set batchFilePath="C:\TestDB\db_script\folder" | |
| rem 程式開始執行 | |
| cd %batchFilePath% | |
| FOR /f %%i IN ('DIR *.Sql /B') do call :RunScript %%i | |
| GOTO :END | |
| :RunScript | |
| Echo Executing %1 | |
| sqlcmd -S %dbIp% -d %dbName% -U %dbUsrAcc% -P %dbUsrPwd% -i %1 >>view.log | |
| Echo Completed %1 | |
| :END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment