-1

I need to have the inputs entered into a parameter query in Excel WRITTEN to specific cells. Is this even possible?

To elaborate for better understanding, this is the SQL statement to pull data from the SQL server

{call dbo.SWMF_MXSalesJW (?,?)} 

So when the connection is refreshed and the box to enter the parameters comes up, whatever date the user enters, I need that value written to Excel cell Z1.

Launenhaft
  • 41
  • 1
  • 6
  • No it has not. I am not asking how to use a parametized query. I am asking how to write the parameters the user inputs to a cell. NOT the data from SQL or how to use cell data as the parameter value. – Launenhaft Jan 03 '19 at 19:21
  • Please read the question asked. You are misunderstanding what is being requested teylyn. – Launenhaft Jan 03 '19 at 19:22

1 Answers1

0

Try to add one more parameter to your procedure

alter procedure sp_test
     @dt_start date
    ,@dt_end date
    ,@need_params_back bit = 0 -- new param
as
begin
    if @need_params_back = 0
    begin
        -- here is your code, for example:
        select 1 as value
        union all 
        select 2
    end
    else
    begin
        -- returning your params
        select 
             @dt_start  as dt_start
            ,@dt_end    as dt_end
    end 
end

And call it twice in excel: first time (let's name it Q1) with need_params_back = 1,

{call dbo.sp_test(?,?,1)}

you don't need here to map parameters to cells, let user input them.

second time (let's call it Q2) - as in your question.

{call dbo.sp_test(?,?,0)}

and map parameters to results of our first query (Q1).

But using such approach leads you to data refresh order, because you firstly need to update Q1 and only after you get results, update Q2 and all your other connections.

I hope, I've understood you correctly.

Alex Sham
  • 489
  • 7
  • 14
  • This does not answer the question. What you have indicated creates a parameter query but does NOT write the value to a cell (this is what I asked for help with). As stated before, I do not need assistance with creating a parameter query. – Launenhaft Jan 03 '19 at 22:35
  • I have re-written the question to see if this will help convey what I am asking. – Launenhaft Jan 04 '19 at 20:44
  • I have re-written answer, hope now it satisfies your question. – Alex Sham Jan 04 '19 at 23:41
  • I do need to map the entered parameter to a cell. Is is possible to have the parameter entered by the user written to a cell? – Launenhaft Jan 18 '19 at 13:43
  • Yes, it is. Connection properties -> Definition -> "Parameters..." – Alex Sham Jan 18 '19 at 13:54
  • Please edit your question and provide images or cases with what you want to get. – Alex Sham Jan 18 '19 at 20:49
  • I want the value entered by the user for ? in the SQL statement to be written to a cell NOT pulled from a cell. Is that possible? – Launenhaft Jan 31 '19 at 15:49