Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 BACKUP A DATABASE

Author  Topic 

GaneshRamanan
Starting Member

40 Posts

Posted - 2011-01-20 : 14:12:58
Hi,


I am taking backup in express edition, when I am running this SP It overwrites the existing file, can you please tell me how to add the getdate() along with the database name, so that will not overwrite the Existing backup.

ALTER PROCEDURE [dbo].[FULLBACKUP]
AS

BACKUP DATABASE [HIS] TO DISK = N'E:\HIS.bak' WITH NOFORMAT, NOINIT,
NAME = N'HIS Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10

Thanks in Advance,
Ganesh Ramanan

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-20 : 14:52:35
[code]Declare @dt char(8)
Declare @location varchar(128)

SET @dt = Convert(char(8), getdate(), 112)
SET @location = 'E:\HIS' + @dt + '.bak'

BACKUP DATABASE [HIS] TO DISK = @location
WITH
NAME = N'HIS Full Database Backup',
STATS = 10;
GO[/code]
Go to Top of Page

GaneshRamanan
Starting Member

40 Posts

Posted - 2011-01-20 : 16:06:21
Thank you very much..
It works..
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-01-20 : 22:33:31
Welcome
Go to Top of Page
   

- Advertisement -