SQL Server 2008 automatic backup error not Integration Services service

Source: Internet
Author: User
Tags getdate

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.