Excel VBA-通过宏在SQL Server中执行作业 [英] Excel VBA - Executing a job within SQL Server via a macro

查看:123
本文介绍了Excel VBA-通过宏在SQL Server中执行作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个作业存储在数据库中,计划每天运行.但是有时有必要在任何给定时间执行此作业以查看最新数据(我正在使用SQL Server Management Studio 2008).

I have a job stored on a database, scheduled to run every day. But its sometimes necessary to want to execute this job at any given time to view up to date data (I'm using SQL Server Management Studio 2008).

作业本身只是从包含实时数据的视图中获取数据,然后将其放入表中,然后该表将用作excel文件的数据源.执行作业删除并使用新数据重新创建表.

The job itself simply takes data from a view which contains live data and puts it into a table which will then be used as a data source for an excel file. Executing the job drops and re-creates the table with fresh data.

在excel(2010)中,我希望有一个按钮",按下该按钮将执行作业,然后在excel中的数据"选项卡上单击刷新",然后将使用新数据更新工作表上的数据.

In excel (2010), i wish to have a 'button' which which pressed will execute the job and then hitting refresh on the data tab in excel will then update the data on the sheet with the fresh data.

我的问题是:我如何从excel宏执行这项工作?

推荐答案

您创建一个将数据从视图移动到表的SP. 然后修改按计划执行该SP的作业. 然后在Excel Macro中,您可以仅使用该SP来更新数据.

You create a SP that moves data from view to table. Then modify the Job that it executes that SP by schedule. Then in Excel Macro you can just use that SP to update the data.

或者参见示例如何从VBScript运行作业

Or see example how to run the Job from VBScript

这篇关于Excel VBA-通过宏在SQL Server中执行作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆