0

So I have a lot of table create scripts that I need to run on a fresh database. They are all in one folder, and theirs over 250 of them.

Is there a good way to go about doing this using SSMS?

  • possible duplicate of http://stackoverflow.com/questions/10261855/how-to-run-sql-script-using-sql-server-management-studio – SMA Oct 17 '14 at 12:26
  • Doh! Does that mean that you can execute scripts in any order? No constraints between tables, no foreign keys, no nothing? – David Brabant Oct 17 '14 at 12:26
  • Using SSMS? Not that I know of. May want to make a batch file or a script. – Jake Oct 17 '14 at 12:31
  • Consider reading their names. I am sure one of them is a control script of some sort. It is very unlikely you have no order implied here - referential integrity creation demands both tables to exist. I am also sure whoever created those scripts has an idea what to do with them. Or are a fragment of non-competence (like the SQL from VS SSDT copied to "deploy them" when they are not meant for this). – TomTom Oct 17 '14 at 12:59

1 Answers1

0

Option 1: USE BATCH FILE

Using Batch file[to run all the scripts in one click] but that cmd implicitly will use sqlcmd.

Option 2: MERGE MULTIPLE SQL FILES INTO A SINGLE SQL FILE AND THEN EXECUTE IN SSMS IN ONE SHOT

Create a simple batch file under the folder(wherein your 250 table creation scripts reside) as follows

type *.sql > allinone.sql

Note: Open txt document and then copy paste the above content and then save it with extension .bat(Ex:merge.bat)
Just double clicking that batch file will give you the single sql file which you can run in SSMS in single go.

knkarthick24
  • 3,106
  • 15
  • 21