Excel: Send multiple values in “Command text”

Deadly 提交于 2019-12-11 02:37:09

问题


Located in the "Data > Connections > Properties > Definition (tab) > Command text", I have the following:

{Call SP_calculo_algo(?)}

Where currently the function receives only one value through the unique parameter that it has, that according with someone told me it is represented by the character of the question mark (?).

What I need is to send two (2) values through the function, since I have the SQL query that returns data that refer to a range between two dates. For example: Start Date (parameter 1) and End Date (parameter 2).

Can you help me?


回答1:


Make sure you are using Microsoft Query for your connection.

Data -> From Other Sources -> From Microsoft Query

At the end of the Wizard, make sure you specify "Return data to Microsoft Excel".

After the query executes, the data will be on your worksheet. Click somewhere on the result set, then select the query Data -> Connections -> Properties.

Click on the definition tab. Modify the command text to include the query with question marks as placeholders for your parameters.

Click OK, and you will be prompted for each parameter. Click the box if you want to save the value you enter for future refreshes.



来源:https://stackoverflow.com/questions/14346563/excel-send-multiple-values-in-command-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!