Wednesday, March 21, 2012

Database Backup

Hi,

I want to know how to take a database backup in sqlexpress from command line. Can some one help me?

Thanks.

At it's most simple, you'd use something like this:

SQLCmd -S .\SQLEXPRESS -E -Q "BACKUP DATABASE AdventureWorks TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\AdventureWorks.bak'"

This isn't teribly flexible or robust, so you're more likely going to want to write a backup script and call that script file rather than just typing in a simple T-SQL command. Read the BOL topic on BACKUP for information about the various options. You can find a general overview of database backup here.

Jasper Smith, one of the SQL Server MVPs, has put together a tool called ExpressMaint that will help you create a script to do maintenance tasks, including backup, check it out.

Mike

|||Thanks.

No comments:

Post a Comment