January 02, 2008

How to back up a database using script in SQL SERVER 2005

Use this script in order to backup a database :

/*
Author : Suprotim Agarwal
Creation Date: Jan 2, 2008
*/
CREATE PROCEDURE [dbo].[usersp_BackUpDB]
@DBNAME nvarchar(50),
@PATH nvarchar(200),
@BCKUPNAME nvarchar(50)
AS
BACKUP DATABASE @DBNAME
TO DISK = @PATH
WITH NOFORMAT, NOINIT,
NAME = @BCKUPNAME,
STATS = 10

You can call this script using :

DECLARE @return_value int
EXEC @return_value = [dbo].[usersp_BackUpDB]
@DBNAME = N'Northwind',
@PATH = N'C:\temp\Northwind.bak',
@BCKUPNAME = N'NW'
SELECT 'Return Value' = @return_value
GO

Read more about this topic over here :

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


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

2 comments:

Anonymous said...

This is a very good web site for SQL Server

Anonymous said...

This is a very good web site for SQL Server