Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to backup the schema of a sql server 2005 database from the command line. Whats the best way to do this?

Update

I ended up buying SQL Compare 8.1 from Red Gate Software.

It works just as well as Change Director and is 1500 dollars cheaper.

share|improve this question
add comment

4 Answers

The other responses about not having a command line tool are true, but there are third party applications to do this.

Disclaimer: I work for Quest Software, who sells Change Director for SQL Server. It does schema-only snapshots, plus notifies you if the schema changes. It can monitor tons of servers, and you can use it to sync schemas between multiple servers, like development and production.

share|improve this answer
add comment

Use the BACKUP DATABASE command to backup the entire database. This will backup the schema and the data. There isn't a single command to script out just the schema.

share|improve this answer
add comment

The schema specifically, and not the data? Why are you backing up just the schema? You should be preserving your source code, not trying to retrieve it from your database.

To specifically script schema objects, have a look at SMO or PowerShell. This SMO method (Schema.Script) might be useful.

For full backups (schema and data) you can issue a BACKUP DATABASE command via SQLCMD.

share|improve this answer
add comment

Found that my question was a duplicate to the same question on www.stackoverflow.com

http://stackoverflow.com/questions/3589/backup-sql-schema-only

The answer there was to right click on the database and select Tasks->Generate Scripts

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.