SQL Server Admin
T-SQL Articles

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



 
  Feedback:

comments

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

    This is a very good web site for SQL Server

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

    This is a very good web site for SQL Server

 

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