The Best Way to Backup SQL Server
December 9th, 2007 by Andrew Chen
When I first learn how to use SQL server the only way I knew to backup SQL server was to use Enterprise Manger. In fact Enterprise Manger (Management Studio for SQL 2005) is a very advance and easy to use database management tool. You can pretty much do everything
New user of database system will think that the learning curve of using SQL server is much shorter but in fact that may be just a miss-conception. By the time you realize that you may have already invested money and time. Of course you won’t regret because SQL server is excellent database system.
Anyway Enterprise Manger is great tool and it can let you backup and restore database easily but what if you have 20 database servers. Maybe it is not too much for you set up the maintenance plan in Enterprise Manger one by one. I remember one of my formal colleague mentioned that on average a SQL server DBA should manage 100 SQL servers. Think about those hosting companies that provide SQL database hosting. They probably have several hundred SQL servers and tens of thousands of SQL databases. Setting up maintenance plan one by one is just very labor intensive.
An alternative way to backup SQL server is to use SQL script. Enterprise manger does that for you behind the scenes. A simple statement like the following can let you backup and restore SQL databases.
Backup Database DatabaseName to DISK='c:\BackupFile'
Restore Database DatabaseName from DISK='c:\BackupFile'
The best thing about these two statements is that you can pass variables as the database name and the backup file name. So they are totally dynamic. If you know a list of SQL server name you can write a script to loop through each server, connect to them, get a list of database they have and send a backup statement. You can do that with one SQL server then you can do that with any number of servers.


[…] it makes complex things look simple and that encourages people to learn. I mentioned about that in my earlier post. Do you think Visual Basic is simple? For those people who just start learning programming they […]