0

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.

4 Answers 4

1

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.

0

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.

0

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.

0

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .