views:

329

answers:

5

Hi,

I have a website I've created in Visual Studio 2008 and I need to take it live. How can I backup the database file to a .bak so I can hand it over to the hosting company to place on the server?

A: 

You don't need a backup to do so (I assume you are using the AttachDbFilename model that Visual Studio uses by default). Just send them the mdf and tell them to attach it to their SQL server instance.

Mehrdad Afshari
+1  A: 

In ssms right click on the database, go to tasks, click back up. should be self explanatory from there.

kscott
I guess he's using SQL Express and relying on auto attach feature. This won't work in that case.
Mehrdad Afshari
A: 

Go to Microsoft Server Management Studio and right click on your database name. Go to "Tasks" -> "Back Up..."

Then assign your properties, ensure that "Backup Type" is full.

Then at the right there is a button "Add" press that and set your filename, ensure that you place the extension .bak at the end of the file name.

Finally hit ok and wait for the backup to complete.

MSDN also has an article that explains this http://msdn.microsoft.com/en-us/library/ms187510.aspx

Nathan Koop
+3  A: 

From a SQL prompt:

BACKUP DATABASE MyDatabase TO DISK='E:\MyDatabase.bak'
andyh_ky
I guess he's using SQL Express and relying on auto attach feature. This won't work in that case.
Mehrdad Afshari
If he's using a SQL Express DB, the answer still applies. You just get to a SQL prompt by using OSQL (usually located in your PATH)
andyh_ky
@bofe: The database will be attached to SQLExpress user instance. It won't be there in the primary instance. This will cause a lot of confusion.
Mehrdad Afshari
I've tried this SQL prompt before, it didn't work. The database was auto created when I started my project, it is a DotNetNuke website.
@Matt Doak: What's the error message?
Mehrdad Afshari
Incorrect syntax at 'Database' <-- that's the name of my database, here is what I entered... BACKUP DATABASE Database TO DISK='C:\Database.bak'
Rename your database and try again. It may be a reserved word.
andyh_ky
If it's REALLY called Database, try with square brackets like: BACKUP DATABASE [Database] TO DISK
Andomar
A: 

I assume you use SQL Server.

This link will guide you:

How to: Back Up a Database (SQL Server Management Studio) -

NinethSense