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

Re: Creating and Deleting Backup 80 80

Done :) I have checked it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.