June 2, 2009 at 2:56 am
hi to all,
how can i create a batch file to execute bunch of scripts in production server. i.e., we have to give the production servername,databasename as input to that batch file.
thanks
🙂
June 2, 2009 at 3:15 am
Hi,
Good question but I hope you understand that Programming cannot be taught. You can try downloading scripts from SQL Server Central and accordingly write your own. Below is a good link which will tell more on this side.
http://www.microsoft.com/technet/scriptcenter/scripts/sql/default.mspx?mfr=true
Regards
GURSETHI
June 2, 2009 at 4:08 am
You can use sqlcmd in the batch
example script:
SET usernamevar=sa
SET pwdvar=DATABASEPASSWORD
SET sernamevar=DATABASESERVER
SET dbnamevar=DATABASENAME
sqlcmd -U %usernamevar% -P %pwdvar% -S %sernamevar%-d %dbnamevar% -i DATABASESCRIPT.sql -o DATABASESCRIPTREPORT.txt
June 2, 2009 at 6:08 am
Hi,
thanks for your great response. it was very useful to me.
Thank you,
🙂
June 2, 2009 at 6:09 am
hi,
i have tried with this :
SET usernamevar=
SET /P usernamevar=Enter Username:
SET pwdvar=
SET /P pwdvar=enter password:
SET sernamevar=
SET /P sernamevar=Enter servername:
SET dbnamevar
SET /P dbnamevar=Enter databasename:
sqlcmd -U %usernamevar% -P %pwdvar% -S %sernamevar% -d %dbnamevar% -i DATABASESCRIPT.sql -o DATABASESCRIPTREPORT.txt
🙂
June 4, 2009 at 7:23 am
There is also the OSQL command that you could call from a BATCH file. Here's an example below:
osql -E -n-1 -q "Select * From SERVER.DB.DBO.Table"
Google / Knowledge base search for more details on the command.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply