The script statement follows the completion
DECLARE @dbname NVARCHAR (20)
SET @dbname =n ' AA '-the name of the library you need to back up
--Define backup time, accurate to seconds
DECLARE @date NVARCHAR (64)
SELECT @date = SUBSTRING (CONVERT (VARCHAR), GETDATE (), 121), 1, 4) + ' _ '
+ SUBSTRING (CONVERT (VARCHAR), GETDATE (), 121), 6, 2) + ' _ '
+ SUBSTRING (CONVERT (VARCHAR), GETDATE (), 121), 9, 2) + ' _ '
+ CONVERT (CHAR (2), DATEPART (hh, GETDATE ()))
+ CONVERT (CHAR (2), DATEPART (MI, GETDATE ()))
+ CONVERT (CHAR (2), DATEPART (SS, GETDATE ()))
--Define the name of the database to be backed up
DECLARE @db NVARCHAR (20)
SET @db = ' + @dbname + '
--Define the full name of the backup file
DECLARE @bakname NVARCHAR (128)
SELECT @bakname = @db + ' _ ' + @date
--Define the backup storage path
DECLARE @disk NVARCHAR (256)
SELECT @disk = N ' e:\databasebackup\ ' + @bakname + '. Bak '--Backup path name
--Define Backup description
DECLARE @name NVARCHAR (128)
SELECT @name = @db + '-Full database backup '
--Defining error messages
DECLARE @error NVARCHAR (128)
SELECT @error = ' validation failed. Unable to find backup information for database "' + @db + '". ‘
BACKUP DATABASE @db to DISK = @disk with Copy_only, Noformat, Noinit,
NAME[email protected], SKIP, Norewind, nounload, STATS = ten, CHECKSUM;
DECLARE @backupSetId as INT
SELECT @backupSetId = Position
From msdb: Backupset
WHERE database_name = @db
and backup_set_id = (SELECT MAX (backup_set_id)
From msdb: Backupset
WHERE database_name = @db
)
IF @backupSetId is NULL
BEGIN
RAISERROR (@error, 16, 1)
END
RESTORE verifyonly from DISK = @disk with FILE = @backupSetId, Nounload, Norewind
GO
SQL Server 2008 automatic backup error not Integration Services service