0

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

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by abelLazm
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.