本文介绍了为所有SQL Server作业自动创建脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我正在尝试为我的MS SQL2005 Server的所有SQL作业自动生成一个创建脚本.
Currently I'm trying to automatically generate a create script for all my SQL jobs of a MS SQL2005 Server.
- 我找到的一种方法已经完成手动地 http://msdn.microsoft.com/en-us/library/ms191450.aspx
- 我发现的第二种方法可以完成自动但我没有直接访问SQL Server. http://relatedterms.com/thread/1916663/Can%20I%20script%20out%20SQL%20Server%20jobs%20以编程方式
- One method I found was donemanuallyhttp://msdn.microsoft.com/en-us/library/ms191450.aspx
- A second method I found could be doneautomatically but I don't have directaccess to the SQL server.http://relatedterms.com/thread/1916663/Can%20I%20script%20out%20SQL%20Server%20jobs%20programmatically
有人知道一个好的TSQL语句或一个简单的程序吗?
Does anyone know a good TSQL statement or a simple program for this?
推荐答案
进一步研究后,我发现了一个很好的脚本可以胜任 Generate-Scripts- for-SQL-Server-Objects
After some further investigation I found a good script that did the jobGenerate-Scripts-for-SQL-Server-Objects
下面的代码是我所需要的:
The code below is what I needed:
DECLARE @object int
exec sp_OACreate 'SQLDMO.SQLServer', @object OUT
exec sp_OASetProperty @object, 'LoginSecure', TRUE
exec sp_OAMethod @object,'Connect(sqltest)'
exec sp_OAMethod @object, 'Jobserver.Jobs().Script()'
exec sp_OADestroy @object
仍然感谢您的帮助
这篇关于为所有SQL Server作业自动创建脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!