Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge multiple SQL files into a single SQL file

I want to merge multiple SQL files into a single SQL file. All I could find over the internet is to create a batch file and execute all the files. However, I want to create a single script file. Any help would be appreciated?

Also, can this be done using C#?

like image 728
Sid M Avatar asked Oct 23 '25 06:10

Sid M


1 Answers

assuming your files are in one place/folder

you can use like this from the command line in windows,

cd c:\folder

for %F in (*.sql) do ( type %F >> final.sql )

Note: >> is used for appending to an existing file, wherein > will overwrite the file everytime

like image 128
Nizam - Madurai Avatar answered Oct 24 '25 18:10

Nizam - Madurai