Problem
Our business users are very savvy with Microsoft Excel. The issue we struggle with is getting the SQL Server data to them in a streamlined manner. We are familiar with some of your earlier tips related to integrating Microsoft Excel and SQL Server. We have gone down the paths and they have been helpful for a number of standardized reports. Now that the users can see the data, we are getting a number of requests to modify reports on a daily basis. Unfortunately, we do not have the staff to support all of the reporting needs. Do you have any suggestions to conduct SQL Server reporting directly with Microsoft Excel from a user perspective?
Solution
That is a great question. A number of tips have been written on MSSQLTips.com (Export data from SQL Server to Excel, Different Options for Importing Data into SQL Server, Insert data from Excel to SQL Server 2005 by using copy and paste commands, etc.) related to SQL Server and Microsoft Excel integration. More options are available in the marketplace natively with Microsoft Office, SQL Server, Reporting Services and third party tools. In this tip let’s work through setting up a PivotTable in Microsoft Excel 2003 from data in the SQL Server 2005 AdventureWorks database. In a nutshell, we will do the following:
- Setup connection between Microsoft Excel and SQL Server
- Define the data, report definition and layout
- Save the report for re-execution or future modification
How to setup Microsoft Excel reporting with SQL Server
Below outlines the detailed steps to create a Microsoft Excel PivotTable accessing data in SQL Server:
Microsoft Excel Reporting from a SQL Server Database
Step 1 – To start the PivotTable and PivotChart Wizard, open Excel and navigate to the ‘Data’ menu and select the ‘PivotTable and PivotChart Report…’ option.
To interact with SQL Server, select the ‘External data source’ radio button.
Press the ‘Next >’ button to continue the process.

Step 2 – Press the ‘Get Data…’ option to retrieve the data.


Step 4 – Validate Microsoft Query installs properly.



Step 7 – Select the SQL Server and authentication mode (Windows or SQL Server). For an expanded set of options (Database, Language, etc.), click the ‘Options >>’ button.


Step 9 – Select the columns from the applicable table(s) or view(s) to outline what data is included in the report.


Step 11 – If necessary, data can be filtered on a per column basis.


Step 13 – Select the data interface.




Step 17 – Choose the radio button for the appropriate worksheet and once the ‘Layout…’ and ‘Options…’ buttons have been configured, select the ‘Finish’ button to generate the PivotTable.



Step 20 – Final PivotTable with the PivotTable Field List to modify the report.

Next Steps
- The next time you are faced with a recurring report that is not completely standardized, consider building a PivotTable with the steps outlined in this tip. By following these steps, you enable your users to build their own reports, modify reports as needed and execute the reports on demand without any development effort.
- One idea may be to setup custom views or expose needed columns from your existing tables in order for your users to complete their reporting needs.
- To take this a step further, be sure to have an non-OLTP environment available to the users for reporting purposes.
- If you do have some power users in your environment, setting up an infrastructure between SQL Server and Excel to support custom reporting, may yield numerous business and IT benefits.
- Check out these related tips:

Jeremy Kadlec is a Founder, Editor and Author at MSSQLTips.com with more than 300 contributions and 25+ years of SQL Server experience. Jeremy leads a team of more than 300 authors helping millions of SQL Server professionals around the globe every second of the day for the last 20 years. He is also the CTO @ Edgewood Solutions and a six-time SQL Server MVP based on his community contributions. Jeremy brings 25+ years of SQL Server DBA and Developer knowledge to the community and holds a bachelor’s degree from SSU and master’s degree from UMBC.