SQL-数据库备份
---------------------------- 原创SQL备份数据库 ----------------------------
DECLARE @DataBase Nvarchar(100)
DECLARE @DataPath Nvarchar(100)
DECLARE @FileName Nvarchar(100)
DECLARE @BackupFileName Nvarchar(100)
DECLARE @DataDescription Nvarchar(200)
DECLARE @DataMediaName Nvarchar(50)
DECLARE @DataMediaDescription Nvarchar(200)
DECLARE @OkInfo Nvarchar(300)
-- FileName SQL_Backup.sql
-- Power by Love_Computer...
-- http://www.56390.com/
-- Email: love_computer@163.com
-- Date: 2005-02-06
SET @DataBase = 'cnwlw' -----数据库
SET @DataPath = 'D:\' -----路径
SET @FileName = 'SQL_Backup' -----文件名
SET @BackupFileName = @DataPath + @FileName
SET @BackupFileName = @DataPath + 'SQL_' + -----实时备份自动产生文件名,格式[SQL_20050206_16_28]
RTRIM(CONVERT(CHAR(10),GETDATE(),112)) + '_' +
RTRIM(DATEPART(HOUR,GETDATE())) + '_' +
LTRIM(DATEPART(MINUTE,GETDATE()))
SET @DataDescription = 'SQL语句产生的备份,备份时间:' + CONVERT(CHAR(19),GETDATE(),121) --描述
SET @DataMediaName = 'Love_Computer Backup' ---媒体
SET @DataMediaDescription = 'Power by Love_Computer... Email: love_computer@163.com' --媒体描述
SET @OkInfo = '数据库 ' + @DataBase + ' 成功备份至 ' + @BackupFileName
-----希望大家告诉我其中的错误 谢谢!!!-----
-----Email: love_computer@163.com -----------
BACKUP DATABASE @DataBase TO DISK = @BackupFileName
WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10 , NOFORMAT ,
NAME = @DataBase , DESCRIPTION = @DataDescription ,
MEDIANAME = @DataMediaName , MEDIADESCRIPTION = @DataMediaDescription
PRINT @OkInfo
------------------- End ---------------------