views:

21

answers:

1

We have batch files to compile all the sql scripts in a folder against a database. Problem is that we have a couple of thousand scripts and it makes an output file for each script.

It makes it difficult to check for errors and a lot to do cleanup on. Is there any way to output all of the results to one file?

Here is the script we use:

for %%f in (.sql) do sqlcmd -Sservername -i"%%f" -o"%%f.txt" -Uusername -Ppassword -ddatabasename

Regards, Albert

+1  A: 

I never used the for statement before in a batch so I am going to do some reading on it but looking at your example this seems like it should work.

Next line in the Batch add

DEL All.TXT
for %%f in (.txt) do type "%%f" >> All.TXT

This should append all the .txt files into an All.TXT.

Gerhard Weiss
thanks! It worked.
Albert