在 VB.NET 中读取 SQL Server 作业的内容
我正在编写一个应用程序,它将在我们所有客户的系统上调用 SQL Server 作业。
我能够执行它,并等待它完成。它有一个输出文件,其保存位置被硬编码到作业中,但是,这在所有客户端上都不是相同的位置。
由于该作业在减去该值的系统上是相同的,因此我希望我的代码读取作业的脚本并解析出位置。
我无法弄清楚如何获取工作本身的实际文本。
这在.NET 中可能吗?如果是这样,怎么办?
I am writing an application that will call a SQL Server job on all our client's systems.
I'm able to execute it, and wait until it's finished. It has an output file that's save location is hard coded into the job however, and this is not the same location on all client's.
Since the job is identical on systems minus this one value, I want my code to read in the script of the job and parse out the location.
I'm having trouble figuring out how to get the actual text of the job itself.
Is this possible in .NET? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下查询获取作业的内容:
从那里,只需在 VB.NET 中创建一个记录集并使用上面的查询。
You can get the contents of the job by using the following query:
From there, just create a recordset in VB.NET and use the query above.
@LittleBobbyTables,有正确的 但是,每当您对系统存储某些内容有疑问时,请查看 SSMS 生成的用于创建对象的脚本。在本例中,一个作业,SSMS 调用多个系统存储过程。您可以查看 SSMS 中的系统存储过程代码,看看内容放在哪里:
只需选择
msdb
数据库,然后选择Programmability
,然后选择Stored procedures
,然后系统存储过程
,然后找到上面列出的那些。右键单击它们并“修改”,这将显示源代码。只是不要保存任何更改!最终成为
msdb.dbo.sysjobs
和msdb.dbo.sysjobs
@LittleBobbyTables, has the correct query. However, whenever you are in doubt or where the system stores something, look at the script that SSMS generates to create the object. In this case, a job, SSMS calls several system stored procedures. You can look at the system stored procedures code in SSMS and see where things get put:
just select the
msdb
database and thenProgrammability
, thenStored Procedures
, and thenSystem Stored Procedures
, and then find the ones listed above. Right click on them and "Modify", which will bring up the source code. Just don't save any changes!which ends up being
msdb.dbo.sysjobs
andmsdb.dbo.sysjobs