SET MY_SRV=
SET MY_DB=
sqlcmd -x -I -S %MY_SRV% -E -b -h-1 -Q "set nocount on select @@SERVERNAME + ' ' + db_name()"
del README_%MY_SRV%_%MY_DB%.txt README_%MY_SRV%_%MY_DB%_simple.txt
REM used_in_BATCH echo pushd ^"^\^\%%^~p0^" 2^> nul >>README_%MY_SRV%_%MY_DB%.txt
echo pushd ^"^\^\%^~p0^" 2^> nul >README_%MY_SRV%_%MY_DB%.txt
echo @echo off>>README_%MY_SRV%_%MY_DB%.txt
echo mode con cols=280>>README_%MY_SRV%_%MY_DB%.txt
echo mode 6000 280 ^>nul 2^>nul >>README_%MY_SRV%_%MY_DB%.txt
sqlcmd -x -I -S %MY_SRV% -E -b -h-1 -Q ^
"set nocount on select 'REM Will Run on ' + @@SERVERNAME + ' ' + name cmd from ^
sys.databases where name not in ( 'master', 'tempdb', 'model', 'msdb')" >>README_%MY_SRV%_%MY_DB%.txt
sqlcmd -x -I -S %MY_SRV% -E -b -h-1 -Q ^
"set nocount on select 'REM Will Run on ' + @@SERVERNAME + ' ' + name cmd from ^
sys.databases where name not in ( 'master', 'tempdb', 'model', 'msdb')" >>README_%MY_SRV%_%MY_DB%_simple.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
Echo REM Will be run in the following order>>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
FOR /F "delims=|" %x IN ('dir *.sql /b') do echo rem %x>>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
FOR /F "delims=|" %a IN ('dir *.sql /b') DO (^
echo.>>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
echo echo run sqlcmd -x -I -S %MY_SRV% -E -e -b -d %MY_DB% -i ^"%a^" ^
-o ^"%MY_SRV%_%MY_DB%_%a_out.txt^" ,ctrl-c if something is wrong>>README_%MY_SRV%_%MY_DB%.txt
echo echo. >>README_%MY_SRV%_%MY_DB%.txt
echo pause >>README_%MY_SRV%_%MY_DB%.txt
echo echo sqlcmd is running now, please wait ... >>README_%MY_SRV%_%MY_DB%.txt
echo sqlcmd -x -I -S %MY_SRV% -E -e -b -d %MY_DB% -i ^"%a^" -o ^"%MY_SRV%_%MY_DB%_%a_out.txt^" >>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%_simple.txt
echo sqlcmd -x -I -S %MY_SRV% -E -e -b -d %MY_DB% -i ^"%a^" -o ^"%MY_SRV%_%MY_DB%_%a_out.txt^" >>README_%MY_SRV%_%MY_DB%_simple.txt
echo.>>README_%MY_SRV%_%MY_DB%_simple.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
echo REM pause >>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
echo type ^"%MY_SRV%_%MY_DB%_%a_out.txt^" >>README_%MY_SRV%_%MY_DB%.txt
echo dir ^"%MY_SRV%_%MY_DB%_%a_out.txt^"^|findstr /I /v Volume^|findstr /I /v DIRECTORY>>README_%MY_SRV%_%MY_DB%.txt
echo echo read ^"%MY_SRV%_%MY_DB%_%a_out.txt^", ctrl-c if something is wrong>>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
echo.>>README_%MY_SRV%_%MY_DB%.txt
)
echo echo hit enter or any key to exit >>README_%MY_SRV%_%MY_DB%.txt
echo pause >>README_%MY_SRV%_%MY_DB%.txt
echo echo on>>README_%MY_SRV%_%MY_DB%.txt
|