I have the following files in my folder:
Script1.sql
Script2.sql
Script3.sql
The below command executes each script successfully:
@echo off
set /p sname= Please enter the servername:
set /p dbname= Please enter the databasename:
ECHO started the batch process at %TIME% >output.txt
for %%f in (*.sql) do (
sqlcmd.exe -S %sname% -d %dbname% -i %%f >>output.txt
%~f0"
)
pause
Results are
(1 rows affected)
(3 rows affected)
(2 rows affected)
What I would like to know is how can i input the file name after each file is executed and this name stored in the output.txt file ie
(1 rows affected)
Script1.sql
(3 rows affected)
Script2.sql
(2 rows affected)
Script3.sql
Any help appreciated
Just output the file name, what's problem?
for %%f in (*.sql) do (
echo %%~nf >> output.txt
sqlcmd.exe -S %sname% -d %dbname% -i %%f >>output.txt
)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다