If you're manually exporting CSV files from your database and importing them into Excel every day, there's a much better way. Excel's Power Query lets you connect directly to your database, run a SQL query, and load the results into a structured table — one that refreshes with a single click.
This tutorial works with SQL Server, MySQL, PostgreSQL, and SQLite. No coding experience required beyond basic SQL.
What You'll Need
- Excel 2016 or later (Power Query is built in)
- Read access to your database (ask your IT team for credentials)
- For MySQL/PostgreSQL: a free ODBC driver (covered in Step 1)
Step 1 — Install the Database Driver (MySQL/PostgreSQL only)
SQL Server and Access connect natively. For MySQL or PostgreSQL, download the free ODBC driver first:
- MySQL: MySQL Connector/ODBC from dev.mysql.com
- PostgreSQL: psqlODBC from postgresql.org
Install the driver, then restart Excel. SQL Server users can skip this step.
Open Power Query
In Excel, go to Data tab → Get Data → From Database → choose your database type (SQL Server, MySQL, etc.)
Enter Connection Details
Server name or IP address, database name, and your credentials. For SQL Server on your local machine, try "localhost" as the server name.
Write Your SQL Query
In the Advanced Options section, paste your SQL query. Example: SELECT SKU, ItemName, QtyOnHand, ReorderPoint FROM Inventory WHERE QtyOnHand < ReorderPoint ORDER BY QtyOnHand ASC
Preview and Load
Power Query shows a preview of your results. Click "Load" to load the data into Excel as a table, or "Transform Data" to clean it up first.
Set Up Auto-Refresh
Right-click the table → Table → External Data Properties → check "Refresh data when opening the file". Now every time you open Excel, it pulls fresh data automatically.
Sample SQL Queries for Operations Reports
Daily Inventory Snapshot
Orders Shipped Today
Low Stock Items with Supplier Info
How to Schedule Auto-Refresh
For a report that refreshes on a schedule (not just when you open it), you have two options:
- Power Automate: Free with Microsoft 365. Create a flow that opens the Excel file and refreshes the connection on a schedule.
- Windows Task Scheduler + VBA: A macro that refreshes all connections when the file opens, combined with Task Scheduler to open the file at a set time.
🗄️ Get the SQL Report Template — Free
Pre-built Power Query connections. Just plug in your database credentials.
⬇ Download Free Template