I have to execute a bulk of scripts on sql server 2008r2.These scripts are present in many folders and subfolders.I created a batch file to execute these scripts but my problem is i have to put this bat file in a folder to execute the concerned folder's scripts.So, if there are more than 10 folders so i have to put it this bat file 10 times in a folder.Is there any way so that i can put my bat file just once wherever i want(like on desktop) and execute the folder's files?
.bat file:-
for %%G in (*.sql) do sqlcmd /S %1 /d %2 -E -i"%%G" pause
Passing server name and database name using command prompt.