Export Schema in SQL Server 2005

Below are instructions on how to export the SQL schema in SQL Server 2005.

There are two methods where you can do this.

1. Using the GUI

– Open Microsoft SQL Server Management Studio
– Right click on the database that you want to export
– Look and choose the “Generate scripts…” option
– Follow the instructions to generate the sql script

2. By Script

– In order to do this, you have to install the “Database Publishing Wizard” software. Once installed, you can use the following command to export.

sqlpubwiz script ( -C connection_string | -d local_database_name ) (output_file) [switches]

switches:

 Output options:

 [-f] : Overwrite existing files
 [-noschemaqualify] : Output script does not qualify object names with
 schema name.
 [-schemaonly] : Only script schema
 [-dataonly] : Only script data
 [-targetserver] : Specifies what version of SQL Server the script
 should target. Valid versions are "2000", "2005".
 Default Value: 2005
 [-q] : Suppress output
 [-nodropexisting] : Default Value: False

 Local connection related:

 [-C connection_string] : Connection string
 [-d local_database_name] : Database name to script
 [-U local_user_name] : Username
 [-P local_password] : Password
 [-S local_server_name] : Server name