ALTER PROCEDURE [dbo].[pro_backupDB] AS BEGIN SET NOCOUNT ON; declare @fileName nvarchar(255),@path nvarchar(255),@DataBase nvarchar(50); set @path='D:webfiledbBackFileRMmsDB'; set @DataBase='Ribecs'; set @fileName = @path+CONVERT(varchar(10), GETDATE(), 23)+'_Ribecs.BAK'; backup database @DataBase to Disk = @fileName with init; /*Delete Old------------------------------*/ declare @olddate DATETIME /*删除14天以前的备份数据*/ set @olddate = getdate()-14; execute master.dbo.xp_delete_file 0,@path,N'BAK',@olddate; END