简体   繁体   English

使用excel参数并且不使用VBA运行Sql Server存储过程

[英]Running Sql server Stored Procedure with excel parameter and without using VBA

I would like to excecute an sql server stored procedure with a date parameter from excel, the date parameter is an input in a cell of the spreadsheet. 我想从Excel执行带有日期参数的sql服务器存储过程,该日期参数是电子表格单元格中的输入。 Is it possible to do this without using VBA ? 是否可以在不使用VBA的情况下执行此操作? My goal is to get dynamic results every time when i set a new date value in the excel file and the examples that i found are using vba when it is about using the dynamic parameters from the excel file. 我的目标是每次在excel文件中设置新的日期值时都获得动态结果,而我发现的示例是在使用excel文件中的动态参数时使用vba。 Please help if there is a way to do that without vba. 如果有没有vba的方法,请提供帮助。 Thanks in advance 提前致谢

Yes. 是。

Start by using Microsoft query to set up a connection to your database, and as the desired number of parameters... Parameters can be added by putting conditions on the query and entering [] in the value box. 首先使用Microsoft查询来建立与数据库的连接,并使用所需数量的参数...通过在查询上放置条件并在值框中输入[],可以添加参数。

Finish creating the connection then edit the connection, and change the SQL to: 完成创建连接,然后编辑连接,并将SQL更改为:

Dbo.procedurename ? Dbo.procedurename?

The question mark is placeholder for parameters. 问号是参数的占位符。 Link the parameter to cell, and set it to auto update on cell change and your good to go. 将参数链接到单元格,并将其设置为在单元格更改时自动更新,以备不时之需。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM