Friday, March 23, 2012

How can i back-up my database in production environment.

I developed an asp.net application in visual web developer 2005 express edition and SQL sever 2005 express with Advanced services. The application has been deployed and iam wondering what tools are availabel to for backing up my data. Are there any tools i can use to back-up my database. Iam not talking of third party tools but tools a vailable in sql sever 2005 express with advanced services or visual web developer express.

OR can write a vb.net Sub procedure that i run and have my database backed up. If so where can i start or what other options may i explorer.

Hi Dear,

you can backup your datbase by usingMicrosoft SQL Server Management Studio and also by ur VB.NET application

i will try to explain you both ways.

1:By using Microsoft SQL Server Management Studio

Open Management Studio and Right Click On Your Database and go to the Tasks->Backup menu item, Backup Database Dialogbox will be open.

Click Add button in Destination Panel, and choose the Destination File. and simply press OK ( This is the simplest way, but you can customize your backup by choosing different options available on Backup Database Dialog)

2. By VB.NET Application

execute following TSQL statement in your SQL Server

USE

master

EXEC

sp_addumpdevice'disk','MyDataBaseBackup','c:\YourDatabaseBackupDirectory\MyDBBackup.dat'

' and then use following code in your application

' VB.NET Code

Dim conAsNew SqlConnection("ConnectionString")Dim comAsNew SqlCommand("BACKUP DATABASE YourDataBaseName TO MyDataBaseBackup")

com.Connection = con

com.Connection.Open()

com.ExecuteNonQuery()

com.Connection.Close()

Thanks

Regards,

Muhammad Akhtar Shiekh

|||

Oh thanks very much Akhtar,

I want to take on and understand thoroughly the second option(vb.net option) as its looks to be more flexible though a bit complicated. Looks like i have to start with stored procedures, isn't. Please would you point me to a tutorial from microsoft to get me started with the core basics of backingup a database using this approach.

Thanks very much.

|||Check out the BACKUP statement in Books On Line. You might want to schedule it as a job and include it in your weekly maintenance window (if you dont already have one, time to create one) rather than create a VB application for it.|||

The problem all starts with version of sql sever one is using. some of the documentation do not apply to the express version of sql sever so you find your self wasting valuable time reading an article that you later find out does not apply to the product version your running. Iam running sql sever 2005 express edition with advanced sevices in my case.

sql

No comments:

Post a Comment