by sanjay
15. October 2012 10:00
23 Feb 2013
As a developer you will need to supply scripts that upgrade the application database from time to time. You can either bundle all your scripts in one folder , zip them and send to your client and ask them to run by date modified or any other order. But it would be obviously much easier for them to be able to run one individual consolidated script.
This can be done as follows
for %%I in (*.sql) do type "%%I" >> consolidated.sql
One problem you might face is that you might need a new line to be enter after every file.
for this create a loop and put these in a batch file (.bat)
for %%I in (*.sql) do
(
type "%%I" >> consolidated.sql
echo. >> consolidate.sql
)
finally you shall put additional "GO" in the end of every file
for %%I in (*.sql) do
(
type "%%I" >> consolidated.sql
echo. >> consolidated.sql
echo. GO >> consolidate.sql
)
Please drop a comment if you have improvements.