This article will guide users to insert SQL queries in Excel 2010 and create dynamic connections.
Step
Step 1. Click the Data tab, then select From Other Sources as shown in the following screenshot
Step 2. Select “From Data Connection Wizard” from the drop down menu
Step 3. The Data Connection Wizard window will open
Select "ODBC DSN" from the available options, then click "Next".
Step 4. The ODBC Data Sources window will open and display a list of databases available in the organization
Select the appropriate database, then click “Next”.
Step 5. The Select Database and Table window will appear
Step 6. You can now select the database and table containing the data you want to pull
Choose the appropriate database.
Step 7. Click Finish on the “Save Data Connection File and Finish” window
The window will display the file name according to the data selected on the previous screen.
Step 8. The Import Data window will appear
In this window, select the appropriate data, then click "OK".
Step 9. Select “From Data Connection Wizard” from the drop down menu
Step 10. Click the Data tab, then click Connections
In the next window, click Properties.
Step 11. Open the Definitions tab in the next window
Step 12. Write the SQL query in the "Command Text" field, then click "OK"
Excel will display the query result data.