All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP程序安全基础:手工php注入总结_php资料_编程技术
Visual C++ 6.0教程:控制结构之分支结构
PHP入门需要掌握的几种功能代码_[PHP教程]
使用.NET自带的功能制作简单的注册码_.net资料_编程技术
通过PHP连接MYSQL数据库、创建数据库、创建表_php资料_编程技术
如何构造一个C#语言的爬虫程序_.net资料_编程技术
C#,中返回上一页问题代码_[Asp.Net教程]
Zope的优点和Apache+PHP+MySQL的比较_[PHP教程]
C#教程:单线程简介
PHP与MySQL中的SQL注入式漏洞_[PHP教程]
Reading number is top 10 pictures
天安门景物系列(一)
小学生考试又现神作--还有外国的
In 2013 hercules Arnold classic1
Ashlynn Brooke show proud chest measurement1
Sora aoi possession of boudoir2
Entered the goddess in the AD1
Sora aoi on twitter2
Li Zongrui hunting video screenshots2
七步解决性冷淡
The money of more than 100 countries and regions9
Download software ranking
在线棋牌游戏3.05版
WebService在.NET中的实战应用教学视频 → 第5集
Unix video tutorial15
jdk1.5
美女写真2
C#高级编程(第4版)
WebService在.NET中的实战应用教学视频 → 第3集
Boxer's Top ten classic battle4
Popkart Cracked versions Mobile phone games
都市狐狸姑娘传
归海一刀 published in(发表于) 2014/2/1 0:23:29 Edit(编辑)
自动备份SQL,Server数据库中用户创建的Stored,Procedures_[SQL,Server教程]

自动备份SQL,Server数据库中用户创建的Stored,Procedures_[SQL,Server教程]

自动备份SQL Server数据库中用户创建的Stored Procedures_[SQL Server教程]

为了避免意外丢失/损坏辛苦创建的Stored Procedures,或者想恢复到以前版本的Stored Procedures,这样提供了一个有效方法,可以自动将指定数据库中的Stored Procedures进行备份。

1. 在特定的数据库(建议为SQL Server的master数据库)上创建数据表StoredProceduresBackup,用来保存备份的Stored Procedures。


IF OBJECT_ID('StoredProceduresBackup') IS NOT NULL


DROP TABLE StoredProceduresBackup


GO


CREATE TABLE StoredProceduresBackup


(


AutoID INTEGER IDENTITY(1,1) PRIMARY KEY,


InsertDate DATETIME DEFAULT GETDATE(),


DatabaseName VARCHAR(50),


ProcedureName VARCHAR(50),


ProcedureText VARCHAR(4000)


)


GO


2. 创建Stored Procedure名为usp_ProceduresVersion,该Stored Procedure用来将需要备份Stored Procedures的备份到上述创建的数据表中。


其中主要访问sysobjects和syscomments系统表:


(1) sysobjects system table
Contains one row for each object (constraint, default, log, rule, stored procedure, and so on) created within a database. In tempdb only, this table includes a row for each temporary object.


(2) syscomments system table
Contains entries for each view, rule, default, trigger, CHECK constraint, DEFAULT constraint, and stored procedure. The text column contains the original SQL definition statements, which are limited to a maximum size of 4 MB. This table is stored in each database.


(3) source script of stored procedure.


/*


Name: usp_ProceduresVersion


Description: Back up user defined stored-procedures


Author: Rickie


Modification Log: NO


Description Date Changed By


Created procedure 8/27/2004 Rickie


*/


CREATE PROCEDURE usp_ProceduresVersion @DatabaseName NVARCHAR(50)


AS


SET NOCOUNT ON


--This will hold the dynamic string.


DECLARE @strSQL NVARCHAR(4000)


--Set the string


--Only stored procedures


SET @strSQL = 'INSERT INTO master.dbo.StoredProceduresBackup(


DatabaseName,ProcedureName,ProcedureText )


SELECT ''' + @DatabaseName + ''', so.name, sc.text


FROM ' + @DatabaseName + '.dbo.sysobjects so


INNER JOIN ' + @DatabaseName + '.dbo.syscomments sc


ON so.id = sc.id


WHERE so.type = ''p''' + ' and so.status>0


Order By so.id '


--Execute the string


EXEC dbo.sp_executesql @strSQL


GO


3. 创建Job执行上述Stored Procedure


在SQL Server上创建Job,并设定运行计划,这样指定数据库的Stored Procedures就可以自动备份到上述数据表中。




OK. That’s all. Any questions about it, please contact me at rickieleemail@yahoo.com. Have a good luck.







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.