windows - Command Line, File Name for each script executed. SQL -
i have following files in folder:
script1.sql script2.sql script3.sql
the below command executes each script successfully:
@echo off set /p sname= please enter servername: set /p dbname= please enter databasename: echo started batch process @ %time% >output.txt %%f in (*.sql) ( sqlcmd.exe -s %sname% -d %dbname% -i %%f >>output.txt %~f0" ) pause
results
(1 rows affected) (3 rows affected) (2 rows affected)
what know how can input file name after each file executed , name stored in output.txt file ie
(1 rows affected) script1.sql (3 rows affected) script2.sql (2 rows affected) script3.sql
any appreciated
just output file name, what's problem?
for %%f in (*.sql) ( echo %%~nf >> output.txt sqlcmd.exe -s %sname% -d %dbname% -i %%f >>output.txt )
Comments
Post a Comment