May 29, 2009 at 7:15 am
Hi,
I have 20 .sql files to be executed. I am executing one by one in query analyser. But I want to execute all the 20 files as a batch and deliver this batch to client to simplify the process.
How Can I do this?
May 29, 2009 at 7:34 am
You could save all the queries in 1 .sql file separated by the GO statement and then execute the 1 command.
You could create a batch file (.bat) that executes the queries using sqlcmd. Lookup sqlcmd in BOL for syntax.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 29, 2009 at 8:22 am
Or you can add it as a job if it is to be run at a regular interval.
-Roy
May 29, 2009 at 8:26 am
Roy Ernest (5/29/2009)
Or you can add it as a job if it is to be run at a regular interval.
Darn Roy, I was hoping this would have been a suggestion to use PowerShell. 😛
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 29, 2009 at 8:29 am
ooops...Sorry.. 🙂 I have never used powershell so I did not want to make a comment on that. Next time I will know better.
-Roy
May 29, 2009 at 8:34 am
I used to deploy changes like this using osql and a batch file. Now I'd use SQLCMD. The SQL Server install runs .sql files for some things using SQLCMD
May 29, 2009 at 8:52 am
Hi
20 files are huge files I cant add them into single .sql
I have to run those 20 as a bath
Thanks
October 14, 2011 at 4:58 am
Create a batch file and save it in the directory where all the sql files are located. To do that follow the below:
1) Open notepad and copy the below:
for %%G in (*.sql) do sqlcmd /S SQLSRV01 /d accounts -E -i"%%G"
pause
2)Save the file as UAT01.txt
3)Once the file is saved go to the directory where you saved it, and delete .txt and replace it with .bat so it should now read UAT01.bat
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply