Sql 数据库备份

来源:互联网 发布:如何注册知乎账号 编辑:程序博客网 时间:2024/04/28 13:09

数据库备份  作业中的Sql语句:

DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '_')
set @strPath = REPLACE(@strPath, '-' , '_')
set @strPath = REPLACE(@strPath, ' ' , '_')
set @strPath = 'F:/数据库备份/' + myData_'+@strPath + '.bak'
BACKUP DATABASE [myData] TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT

 

作业删除

select * from msdb.dbo.sysmaintplan_subplans  
select * from msdb.dbo.sysmaintplan_log 

delete  from msdb.dbo.sysmaintplan_subplans   
delete  from msdb.dbo.sysmaintplan_log