How to Create SQL-Embedded Excel Reports

synapse88

New Member
Joined
Oct 20, 2005
Messages
2
I want be able to send out excel workbooks with SQL queries embedded.

For example I want to send out a monthly sales report for the month of June, have the user open the report and have the SQL query populate the appropriate cells with June's sales data. I would want the user to be easily change a data value in the query a month later, re-execute the query and have July's sales data.

How would I set something like this up? I'm using Excel 2003 and would be querying a Microsoft SQL Server.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Use MS Query to create a parameterized database query (Data | Import External Data > New database query...)

In the Query UI specify a parameterized critierion. To do so, in the criterion field specify something within square brackets (same principle as in MS Access).

Now, when you return to XL first MS Query will ask you to specify a value for the parameter. Specify any value you like. Then, back in XL, XL will ask you how the parameter should be managed. Your choices will be (a) some literal value, (b) have XL ask the user for a value each time the query is executed, or (c) take the value from a cell. In the last case, an additional option will be to rerun the query whenever the value in the cell changes. If it isn't obvious what you should use, use option (c).

Now, use this data table as the source for whatever further analysis you want to carry out.
 
Upvote 0

Forum statistics

Threads
1,203,203
Messages
6,054,117
Members
444,703
Latest member
pinkyar23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top