Monday, March 31, 2014

How to Embed a SQL Query in Microsoft Excel

This article will help users to embed SQL Query in Excel 2010 and create a dynamic connection in Excel.




  1. Embed a SQL Query in Microsoft Excel Step 1.jpg
    1
    Go to Data tab and select Find Other Sources as shown in the screen shot below.
  2. Embed a SQL Query in Microsoft Excel Step 2.jpg
  3. 2
    Select “From Data Connection Wizard” in the drop down.
  4. Embed a SQL Query in Microsoft Excel Step 3.jpg
    3
    Data Connection Wizard will open. Select “ODBC DSN” from the available option and click “Next”.
  5. Embed a SQL Query in Microsoft Excel Step 4.jpg
    4
    Connect to ODBC Data Source window appears. Where a list of database available in our organization will be displayed. Select the appropriate database and click on “Next”.
  6. Embed a SQL Query in Microsoft Excel Step 5.jpg
    5
    Select Database and Table window appears. We can select the database and the table from where we wish to pull the data. So, select the database and table as appropriate in our case.
  7. Embed a SQL Query in Microsoft Excel Step 6.jpg
    6
    Select Finish in “Save Data Connection File and Finish” window. This window will pull up the File Name based on our selection in previous screens.
  8. Embed a SQL Query in Microsoft Excel Step 7.jpg
    7
    Import Data window appears where we can select options as per our need and click OK.
  9. Embed a SQL Query in Microsoft Excel Step 8.jpg
    8
    Select “From Data Connection Wizard” in the drop down.
  10. Embed a SQL Query in Microsoft Excel Step 9.jpg
    9
    Go to Data tab and Click on Connections. Click on Properties in the following window.
  11. Embed a SQL Query in Microsoft Excel Step 10.jpg
    10
    Go to Definitions tab in the following window and write SQL query in “Command Text” and Click OK. Excel will display the result as per the query.
  12. Embed a SQL Query in Microsoft Excel Step 11.jpg
    11
    Now go to Microsoft Excel and validate if the results are as per the SQL Query written.

No comments:

Post a Comment

OAuth authorization server