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)


Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter


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

 
  Feedback:

comments

2 Responses to "How to back up a database using script in SQL SERVER 2005"
  1. Anonymous said...
    July 11, 2008 at 12:45 AM

    This is a very good web site for SQL Server

  2. Anonymous said...
    July 11, 2008 at 12:46 AM

    This is a very good web site for SQL Server

 

Copyright © 2009-2014 All Rights Reserved for SQLServerCurry.com by Suprotim Agarwal | Terms and Conditions