954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Creating and Deleting Backup

Hey all...

I have assigned a job to create back of the databases of our company, maintain it for 7 days and after 7 days delete the back... I have worked on this and make it up the following query but still confused on its authenticity. Please Check and tell if it is right and safe to be executed? Please help

SET NOCOUNT ON
DECLARE @filename VARCHAR(99), @path VARCHAR(99),@backup VARCHAR(999)
SELECT @filename= 'DBSERVER_MASTER_'+ replace(replace(cast(getdate() as varchar),':','_'),' ','_')
SELECT @path= 'D:\test\'
SELECT @backup=@path+@filename+'1'+'.bak'
BACKUP DATABASE [MIS_DB] 
TO  DISK = @backup 
WITH  RETAINDAYS = 7,INIT ,  
NOUNLOAD ,  
NAME = N'DBSERVER_MASTER-Full Database Backup',  
SKIP ,  
STATS = 10,  
NOFORMAT
go


Thanks in advance

abelLazm
Postaholic
2,113 posts since Feb 2011
Reputation Points: 219
Solved Threads: 124
 

Done :) I have checked it

abelLazm
Postaholic
2,113 posts since Feb 2011
Reputation Points: 219
Solved Threads: 124
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: