if exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Sp_proccopydb] and OBJECTPROPERTY (ID, N ' isprocedure ') = 1) drop procedure [dbo]. [Sp_proccopydb] Go
/*--Database Automatic replication
Copies the database of the specified leading edge to a database with the current month +1 as the library name, and clears all data, for example, the database leading edge is Pos, and the current date is 2005-3-27 requires that the data be copied Pos200503 to Pos200504 and the data inside is emptied
The advantage of using the method of generating the Source library script is that it is fast and does not need to consider the data of the source database but if you want to keep some of the data from the source database, you should do the data replication processing
--operational requirements require the following two files, can be found in the SQL installation disk X86\upgrade directory Scptxfr.exescptxfr.rll
Copy it to the following directory%systemroot% ystem32\--Jiangjian 2005.03 (please keep this information for reference)--*/
/*--Call Example
--Copy posexec sp_proccopydb ' Pos '--*/
--1.master database to create a processed stored procedure to achieve the monthly database to the next month of automatic replication of data
/*--system requirements require the following two files, can be found in the SQL installation disk X86\upgrade directory Scptxfr.exescptxfr.rll
Copy it to the following directory%systemroot% ystem32\--*/
--Create object Set @s=n ' osql/s ' +quotename (CAST (serverproperty (N ' servername ') as nvarchar), N ' "') +n '/d ' + with Source Library script QuoteName (@ddbname, n ' "') +n '/e '--Using Windows authentication, 愀 to +n '/U sa '/P ' sa password ' +n '/I ' +quotename (@bkfile, n '" ") if SQL authentication is used EXEC master.. xp_cmdshell @s,no_output
--Delete temporary backup files set @s= ' del ' + @bkfile + ' "' EXEC master ... xp_cmdshell @s,no_outputgo
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.