Exporting MSSQL database structures

Sometimes I need to create a completely empty database in MSSQL based on another database.  For example to test conversion applications.  The SQL Server Management Studio makes this easy. 

Right click on the database you want to script.  Instead of "Script Database as" option which will _only_ create a script to create the database itself, no tables, views etc. select "Tasks" and then "Generate Scripts"  This starts the Script Wizard which allows you to pick exactly what you want to generate scripts for, what options etc. 


The screenshot above shows the options you have for the script generation.  For a database with about 100 tables, some stored procedures, triggers etc. the script generation takes just a few seconds.  The generated script is fairly readable and includes everything you tell it to include. 

You can select to export the script into a single file, or one file pr. object and you can also select to generated it to a new query window. 



Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk