Home Page

UPDATE: 2010 Developer Action Plan The folks at LearnVisualStudio.NET have created a new Developer Action Plan packed with strategies and advice to help you get that elusive first .NET development job and also become an awesome ASP.NET developer. This action plan is perfect:

  • For those with little or no .NET experience, or...
  • For those with programming experience, but who feel like their skills are deteriorating or becoming stale

If you simply enter your email in the next 15 minutes, you will get:

  • A download link for the 2010 Developer Action Plan
  • 4 hours of free ASP.NET training videos you can watch from the comfort of your computer

By using the SQL Server Management Studio that installs with SQL Server you can perform a number of database administration tasks.  In this lesson I will show you how to backup your SQL Server database to the file system.  Here are some key reasons why you may want to backup a database:

  • To create historical copies of your database schema and data.  In case your system crashes or you mess up the data/table definitions, you can create periodic backups to file and restore them later in the event of such an emergency.  A good example of this scenario is if you messed up some important table definitions and cannot undo your changes.  Another example is if the data in the tables gets erased accidentally.
  • To give your database to somebody else so that they can use it.  If you are collaborating with somebody, it comes in handy to be able to provide them a database backup file so that they can restore it into their SQL Server and they will be able to see all of your tables and data.
  • To deploy the database in another development environment, like on a test system.  Software projects frequently take a snapshot of a development database by using a backup and deploy the database file to another SQL Server by using the Restore Database option.

First, logon to SQL Server Management Studio and expand the Databases list.  Right click on the database that you want to backup and choose “Tasks->Back Up…”.  A popup window called Back Up Database will appear with a bunch of options that you can configure for the backup operation.

Make sure that “Backup type: Full” and “Back up to: Disk” are chosen.  The exact backup file location will vary depending on your exact SQL Server version but it will look something similar to ”C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Backup\shoppingcart_CSharpUniversity.bak”.  This folder is the default SQL Server backup folder.  The default file name for the backup is the name of your database, appended with .bak.

When you are ready to start the backup, click on the OK button and SQL Server will starting writing out the backup file.  When it has completed, it will display a message.  After that occurs, you can access the output file by opening Windows Explorer and navigating to the backup location that was listed in the Back Up Database window.  You can copy the .bak file somewhere else or do whatever you need with it.  You can provide this .bak file to somebody that you are collaborating with and they should be able to restore the database into their SQL Server.  *If they have problems restoring your database backup, check to see if the two versions of SQL Server (yours versus theirs) are not compatible with each other.

Click here to watch a video example of how to backup a SQL Server database to file.

To read a related lesson that shows how to restore a SQL Server database from file click here.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment