日期:2014-05-18 浏览次数:20486 次
USE test GO CREATE PROCEDURE BackupFullDB --BEGIN DECLARE @DBName VARCHAR(100) DECLARE @ym VARCHAR(6) DECLARE @ymd VARCHAR(8) DECLARE @BackupFile VARCHAR(100) DECLARE @BackName VARCHAR(100) DECLARE @tmp VARCHAR(100) DECLARE @backupSetId as int BACKUP DATABASE @DBName, sysname, @DBName TO DISK = @BackupFile WITH NOFORMAT, NOINIT, NAME = @BackName, SKIP, NOREWIND, NOUNLOAD, STATS = 10, CHECKSUM SELECT @backupSetId = position FROM msdb..backupset WHERE database_name = @DBName AND backup_set_id = (SELECT max(backup_set_id) FROM msdb..backupset WHERE database_name = @DBName) IF @backupSetId IS NULL BEGIN raiserror(@tmp, 16, 1) END RESTORE VERIFYONLY FROM DISK = @BackupFile WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
你这个传参数,需要动态凭借你的备份语句啊: set @sql='BACKUP DATABASE '+'''' @DBName''''+', sysname, '+''''@DBName'''' +'TO DISK ='+'''' @BackupFile++++ 后面的也是如此,自己改改吧