Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Creating a batch file

Author  Topic 

vmurali
Yak Posting Veteran

88 Posts

Posted - 2008-06-13 : 02:21:34
Hi All, I need to create a batch file to execute some 5-6 sql scripts. I have sql scripts for creating a table and related storedprocs and I need to generate a batch file to run all this scripts.

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2008-06-13 : 02:47:58
You can create the batch file using sqlcmd for executing your script.. look into bol for further details on sqlcmd..

And for running the batch look out for xp_cmdshell.



Chirag

http://www.chirikworld.com
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2008-06-13 : 03:02:59
Thanks for ur reply. I am new to creation of batch file. Is it like add statements with sqlcmd and save as *.bat file.
How to execute the batch file from command prompt

If possible if you can send me a steps to create a batch file and execute the batch file
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2008-06-13 : 03:07:44
Here is the way to execute the batch file.

http://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql-xp_cmdshell-bat-file/

Here is the command which you require to put in your batch file.

http://msdn.microsoft.com/en-us/library/ms180944.aspx



Chirag

http://www.chirikworld.com
Go to Top of Page
   

- Advertisement -