Data | database
/*--Original post address: http://community.csdn.net/expert/topic/3818/3818559.xml?temp=.9593317--*/
/*--Processing Requirements
There is a database named Pos200502 in the SQL databases, and each month there will be a database similar to this name (Pos200502 Pos200503)
How do I take advantage of SQL Server's automatic job + a stored procedure to achieve the following functions: 1.25th per month, automatically create a next one month Database,database name is set as: Posyyyymm (Yyyymm is the year and month, is always the next month of operation time 2. Copy all of the structure of this month's database (including tables, views, stored procedures, etc.) to the next one-month database. (Note that only the structure is copied, no data is copied!) )--*/
---Method 1. Backup + Restore use Mastergo
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 Backup + Restore method is that when you clean up the data, you can set the conditions to keep the specified data. The data is too long, the speed is slow, and the resources consumed are more
--Jiangjian 2005.03 (please keep this information for reference)--*/
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.