views:

42

answers:

4

I used the Database Publishing Wizard to generate a script of the schema for a database, how do I make a new database based on this .sql file?

A: 

Run the sql file against the database, from the command line client or some other client:

sqlcmd -d databasename < dumpscript.sql
tpdi
A: 

Typically, you would open a query analyzer window (right-click on the server; new query in Management Studio) and just run the script. It depends, though, on what the script contains - i.e. does it create the db - or just the tables. You may need to create the empty db yourself first.

Marc Gravell
+1  A: 

Open the SQL file, and add the CREATE DB syntax to the top.

http://msdn.microsoft.com/en-us/library/aa258257.aspx

Save it and run it with sqlcmd or query analyzer.

Or use Management Studio to create the empty db, and run the sql query against that.

From what I have seen with the sql server publishing wizard, it will not create the DB for you, just the tables and data.

Bob
A: 

I've seen this used where I work - the osql command line utility for MS SQL. You can create databases and run DML queries too via string or file input

Gishu