一、SQL Server Management Studio(SMSS) 维护计划
二、Windows 级 任务计划程序( MSSQL Express)
1) 新建Sql存储过程(master-可编程性-存储过程)
USE [master]
GO
/****** Object: StoredProcedure [dbo].[sp_BackupDatabases] Script Date: 07/08/2019 15:22:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:<十有三>
-- Create date: <2015-03-07>
-- Description: <完整备份InformationManagementSystem>
-- =============================================
ALTER PROCEDURE [dbo].[sp_BackupDatabases]
AS
BEGIN
--设置备份数据库的存放目录
DECLARE @diskPath NVARCHAR(300)
SET @diskPath='X:\**bak\数据库名_'
+CONVERT(VARCHAR, GETDATE(),112)+'_'
+REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')+'.BAK' BACKUP DATABASE BJMS_SMSS TO DISK = @diskPath WITH FORMAT;
END
2)新建批处理
sqlcmd -S . -E -Q "EXEC 数据库.dbo.sp_BackupDatabases"
3)添加任务计划程序 指定任务执行时间