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?

4
  • possible duplicate of stackoverflow.com/questions/10261855/… Commented Oct 17, 2014 at 12:26
  • Doh! Does that mean that you can execute scripts in any order? No constraints between tables, no foreign keys, no nothing? Commented Oct 17, 2014 at 12:26
  • Using SSMS? Not that I know of. May want to make a batch file or a script. Commented Oct 17, 2014 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). Commented Oct 17, 2014 at 12:59

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.