SQL statement copy

Source: Internet
Author: User

Example:

Save the following paragraph as a Text Example of backupscript. SQL
-- Copying master data
Print 'replica master data output'
Backup database [Master] to disk = n' c: \ waterlike \ dB \ master. bak 'with noformat, init, name = n' Master', Skip, norewind, nounload, stats = 10, checksum
Go
Declare @ backupsetid as int
Select @ backupsetid = position from MSDB .. backupset where database_name = n 'master' and backup_set_id = (select max (backup_set_id) from MSDB .. backupset where database_name = n 'master ')
If @ backupsetid is null begin raiserror (n' confirm the loss. Unable to find the metadata 'master. ', 16, 1) End
Restore verifyonly from disk = n'c: \ waterlike \ dB \ master. Bak 'with file = @ backupsetid, nounload, norewind
Go

Save the following parts into a batch of shards:
@ Path = c: \ Program Files \ Microsoft SQL Server \ 90 \ tools \ binn; % Cd %;
Sql0000.exe-I backupscript. SQL-O backupreport.txt

Put them in the same path, and then the computer sets a schedule to regularly run a batch of orders.

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.