数据库备份(存储过程)

USE T_PaotuiChannel
GO
/****** Object:  StoredProcedure [dbo].[T_Paotui_Dic_BackupDBToLocalDisk]    Script Date: 2016/2/13 16:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
---
--- SQL作业
--- 数据库备份
--- 

create proc [dbo].[T_PaotuiChannel_BackupDBToLocalDisk]

AS

DECLARE @FullPath varchar(1000) 
declare @FolderPath varchar(500)
set @FolderPath= 'f:\uupaotui_bak\T_PaotuiChannel\'
set @FullPath = @FolderPath+ 'T_PaotuiChannel_'+convert(VARCHAR(4),year(getdate()))+right( '0'+convert(VARCHAR(2),MONTH(getdate())),2)+right('0'+convert(VARCHAR(2),DAY(getdate())),2)+'_'+ convert(VARCHAR(4),DATEPART(hour,getdate()))+ '.bak'

backup database T_Paotui_Dic to disk=@FullPath WITH INIT

 

你可能感兴趣的:(数据库备份(存储过程))