Hi, My name is Jimmy Sam. If you need DBA help, please email to jimmy_sam001@yahoo.com for further discussion. Thanks.
mssql deployment    

Please Input Your Server Name And Database Name


Server Name:      
Database Name:         Reset



   


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

Deployment Notes 1: right click mouse to open the command prompt


1. Using Windows explorer or Other Gui tools to the folder where your .sql files located

2. Shift + Mouse-Right-button, select "Open Command Window Here"

3. Copy The windows Commands From Internet Explorer to The DOS Prompt
   This will do no harm to the database and only create two files: readme_xxx.txt and readme_xxx_simple.txt 

4. Review and Select one of the readme file and do the real deployment

Deployment Notes 2: file name end with .sql


1. Deployment files must end with .sql, other file names will be ignored. Also don't put filename end with .sql if you don't want to run or deploy that file 

2. All of the files will be executed in alphabetic order, you can click the name column in window expolorer to confirm the order