Here is an interesting problem which I enjoyed solving yesterday.
There were multiple SQL Files in my one folder. When I had to send it to my friend I had to collect all the files into a folder and zip it to send it via email. My friend who was using mobile device told me that it is difficult to see the content of the file on a mobile device so it would be nice if I can just send all the SQL files combined in one single file and send it to him.
I loved the idea, but the challenge was that there are over 100s of the files were there and combining them into a single file would be a manual task for hours. I did not like the solution and I went online to find some cool solution. After a while I found a solution that I can use wiht command prompt to combine multiple files into a single file and it is easy to do so.
Here is an example. Let us create three SQL Files.
Now we will execute the following command in command prompt which will combine all the three files into a single file.
The command is
type *.sql > OneFile.sql
Above command will combine all the three files into a single called OneFile.sql.
Following image displays the content of the OneFile.sql which is the concatenation of all the sql files in the folder.
I enjoyed solving this little problem.
Reference: Pinal Dave (https://blog.sqlauthority.com)
Nice article…Saved a lot of time..!!
thanks a lot for your help! that would helped me a lot!
Lovely, buut, in my case, somewhere it was like this:
and became useless :( Do you have solution for that?
I have files ending with numbers like m1.sql, m2.sql so on till m40.sql. With this approach m10.sql, m11.sql are picked up after m1.sql. Is there a way to get around this issue?
Working fine, but there is an interesting thing happening: i have ~25 files. All are 1-2 kb. I combine them and the resulting file is 86 MB. Checked the file but the content is whats in those 25 files. I think windows is doing something strange here. Still it works on import but uploading such a file to something like phpmyadmin is hard on most webservers :D