How To Connect Excel To A Database
Level: intermediate · ~16 min read · Intent: informational
Audience: data analysts, finance teams, operations teams
Prerequisites
- intermediate spreadsheet literacy
- comfort with formulas or pivot concepts
Key takeaways
- The best way to connect Excel to a database is usually through Data > Get Data, because it creates a refreshable connection, works with Power Query, and lets you keep source logic in the database instead of rebuilding exports manually.
- A strong Excel-to-database workflow depends on more than just making the connection. You also need the right connector or driver, a clear refresh strategy, safe credential handling, and a decision about whether the workbook should load tables directly or use a native SQL query.
FAQ
- Can Excel connect directly to a database?
- Yes. Excel can connect directly to databases through Data > Get Data using supported database connectors, and it can also use legacy Microsoft Query and certain ODBC-style workflows in some environments.
- What is the best way to connect Excel to SQL Server?
- For most modern workflows, the best way is to use Data > Get Data > From Database > From SQL Server Database, then choose the table, view, or SQL query you want and load or transform the data with Power Query.
- Can I refresh database data in Excel?
- Yes. Excel supports refreshable external data connections, and you can refresh manually or configure certain connection properties such as refresh on open depending on the workbook and connection type.
- Should I connect Excel to raw tables or use a query?
- That depends on the workflow. For simple exploration, loading a table or view can be fine. For cleaner and more controlled reporting, using a curated view or a native SQL query is often the better option.
Connecting Excel to a database is one of the most useful upgrades an analyst or reporting team can make because it replaces repeated manual exports with a more direct, refreshable workflow. Instead of asking someone to export a file every week, move columns around, and rebuild pivots from scratch, Excel can often connect to the source data directly and pull in a cleaner result set.
That is why this topic matters.
A lot of people assume “connecting Excel to a database” is only for technical users. It is not. Modern Excel connection workflows are built into the Data tab, and Power Query gives you a visible way to bring data in, shape it, and refresh it later. At the same time, there are still older connection paths such as Microsoft Query and Office Data Connection files that matter in some organizations.
The real question is not only: can Excel connect to a database?
It is:
- which connection path should you use
- what kind of database are you connecting to
- should the workbook load a table, a view, or a query
- how will refresh work
- where should credentials and security be handled
This guide explains how to connect Excel to a database in a practical way, which options Excel supports, when to use modern Get Data flows versus legacy options, and how to avoid the most common setup mistakes.
Overview
For most modern workflows, the default connection path in Excel is:
- Data > Get Data > From Database
- choose the database type
- provide the server and database information
- optionally provide a native SQL query
- preview the data
- load it into Excel or transform it in Power Query first
Microsoft’s current Excel support documentation says you can connect through Data > Get Data > From Database and specifically lists database connectors such as SQL Server, PostgreSQL, MySQL, Oracle, IBM DB2, and Microsoft Access. It also says that for SQL Server you can optionally specify a SQL statement in the SQL Statement box, and similarly for PostgreSQL. citeturn963468view0
That is the modern default.
Excel also still supports older connection routes such as Microsoft Query. Microsoft’s current support documentation says Microsoft Query is available through Data > From Other Sources > From Microsoft Query, and in Microsoft 365 it is now under the Legacy Wizards group that must be enabled in Excel options first. citeturn963468view3
So there is not one single connection method. There are several, and each fits different workflows.
What database connections in Excel are good for
A database connection in Excel is usually the right choice when:
- the workbook should pull structured data repeatedly
- the same data is needed more than once
- the business wants refresh instead of manual re-export
- the source logic should stay in the database
- the workbook is used for pivots, formulas, or review rather than as the original data source
- analysts want to avoid copy-paste workflows
This is especially useful for:
- recurring sales reports
- finance packs
- operational dashboards in Excel
- refreshable lookup tables
- ad hoc analysis on governed source data
- source-driven planning sheets
A lot of Excel workflows improve immediately once the team stops relying on static exports.
The modern default: Get Data and Power Query
For most users, the best starting point is the modern Get Data workflow.
Microsoft’s current support documentation says:
- for SQL Server: Data > Get Data > From Database > From SQL Server Database
- for PostgreSQL: Data > Get Data > From Database > From PostgreSQL Database
- for MySQL: Data > Get Data > From Database > From MySQL Database
- and similar flows exist for other supported database connectors. citeturn963468view0
This matters because Power Query is built into that workflow.
That means you can:
- connect to the database
- preview the result
- clean or shape the data
- rename columns
- set types
- filter rows
- load the result into a worksheet or data model
- refresh it later
This is usually much better than opening an exported file and cleaning it manually every time.
Common databases Excel can connect to
The exact connector list can vary by version and platform, but Microsoft’s current support page shows modern Excel support for connectors including:
- SQL Server
- Microsoft Access
- MySQL
- PostgreSQL
- Teradata
- Sybase
- Oracle
- IBM DB2 and various file and web-based sources as well. citeturn963468view0
That means the general pattern is broad, even though the exact setup may differ by database.
A practical guide should still make one thing clear: just because the menu supports the database does not always mean the environment is ready.
Sometimes you still need:
- the right network access
- database credentials
- an ODBC driver or provider for certain sources
- permission to run queries
- approved connection settings from your data or IT team
For example, Microsoft’s support page notes that some connectors, such as MySQL, require an additional ODBC driver before they can be used. citeturn963468view0
So the menu path is only part of the setup.
SQL Server example
SQL Server is one of the clearest examples because Microsoft documents it directly.
Microsoft’s support documentation says to connect from Excel:
- Select Data > Get Data > From Database > From SQL Server Database.
- Enter the server name.
- Optionally specify the database name.
- If you want to use a native query, put the SQL in the SQL Statement box. citeturn963468view0turn963468view1
This is one of the most common Excel-to-database paths in business environments.
A strong practice here is to decide whether the workbook should connect to:
- a raw table
- a view
- or a curated SQL query
For many business-facing workbooks, a view or curated query is often better than a raw table because it reduces clutter and keeps business logic closer to the source.
PostgreSQL example
Excel also supports PostgreSQL through Get Data.
Microsoft’s support documentation says to connect:
- Select Data > Get Data > From Database > From PostgreSQL Database.
- Enter the PostgreSQL server name.
- Optionally specify a native SQL query in the SQL Statement box. citeturn963468view0
This is useful when:
- teams are moving from spreadsheets to PostgreSQL-backed reporting
- Excel is still the preferred review or delivery layer
- analysts need refreshable workbook access without moving everything into Power BI
The workflow idea is the same even though the database engine changes.
Native SQL queries in Excel
Sometimes you do not want Excel to connect to a table and then shape everything afterward. Sometimes you want the database to return exactly the dataset you need.
Microsoft’s support documentation says you can provide a native database query in the SQL Statement box when connecting to a database, and that the procedure is similar across supported databases. citeturn963468view1turn963468view0
This is useful when:
- the result should be tightly controlled
- you already know the exact SQL you want
- the source query should filter rows early
- the workbook should only receive a curated result
- you want less cleanup on the Excel side
A practical rule is: use a table or view when the source object is already clean enough; use a native query when the workbook needs a specific shaped result that the source object does not provide cleanly.
Refreshing the data later
A database connection is much more useful when it can refresh.
Microsoft’s Excel support documentation says Excel workbooks can connect to an external data source, that Excel creates connection information the first time data is imported, and that you can perform a refresh operation to retrieve updated data. It also states that refresh properties can be configured, including refresh on open in some cases. citeturn963468view2
This matters because many teams do not actually need a database connection if they only want a one-time export. The real value appears when the workbook becomes:
- recurring
- refreshable
- reusable
- less dependent on manual file exports
A strong refreshable workflow depends on:
- stable source objects
- correct credentials
- predictable connection settings
- workbook users understanding when and how to refresh
Credentials and security
Connecting Excel to a database is not only about the server name.
You also need to think about:
- user credentials
- stored passwords
- trusted locations
- whether the workbook should refresh automatically
- whether the connection file is safe to share
Microsoft’s current refresh documentation says external data connections often require credentials and warns users to handle them carefully. It also notes that external data may be disabled by security settings, and that connections can be refreshed only when trust and access requirements are satisfied. citeturn963468view2
That means a practical production setup should answer:
- who owns the credentials
- who is allowed to refresh
- whether the workbook will circulate outside the core team
- whether direct source access is appropriate for all recipients
This is especially important when the workbook is widely shared.
Office Data Connection files and saved connections
In some environments, connection details may be saved and reused.
Microsoft’s Excel refresh documentation says connection information is sometimes saved in an Office Data Connection (.odc) file. Microsoft’s Azure SQL Excel connection documentation also says you can create a permanent connection using an .odc file and then reuse it through the Existing Connections dialog in Excel. citeturn963468view2turn963468view4
This is useful when:
- many workbooks use the same source
- connection setup should be standardized
- IT or a central analytics team wants to control the connection definition
- users should pick from existing trusted connections rather than rebuild them manually
This is more common in managed environments than in ad hoc analyst work, but it is still very relevant.
The legacy option: Microsoft Query
Microsoft Query still matters in some Excel workflows, especially when a legacy ODBC-style setup already exists.
Microsoft’s support documentation says:
- Microsoft Query connects to an external database through a data source
- after you set up the data source, you can reuse it without retyping the connection information
- in Excel 365, Microsoft Query is hidden under the Legacy Wizards group and must be enabled in Excel options first. citeturn963468view3
This is not the modern default for most users. But it is still useful when:
- the organization already relies on Microsoft Query
- a legacy data source or DSN is already configured
- the workbook has to fit into an older reporting process
- Power Query is not the chosen path for that environment
A practical guide should mention it because many corporate Excel workflows still rely on it.
Table, view, or query?
Once the database connection works, the next question is what the workbook should actually pull.
Connect to a raw table when:
- you are exploring the source
- the table is already small and well shaped
- the workbook is analytical and temporary
Connect to a view when:
- the business logic should stay centralized
- many users need the same cleaned source
- the report should use a stable, curated object
Use a native query when:
- the workbook needs a very specific result
- filtering and shaping should happen in the database
- the result should be leaner than the raw source object
For many recurring workbooks, a curated view or controlled query is the best balance.
Worksheet load vs Data Model
After the connection is created, you still have to decide where the data should go.
You can often:
- load to a worksheet table
- load to the Data Model
- or do both depending on the workflow
A worksheet table is useful when:
- users need to see the rows directly
- formulas and ordinary Excel references matter
- the dataset is moderate in size
The Data Model becomes more useful when:
- the dataset is larger
- relationships matter
- Power Pivot-style analysis is useful
- the workbook should avoid overloading a visible sheet
This decision becomes especially important as row volume grows.
Common mistakes when connecting Excel to a database
Mistake 1: Connecting to raw source tables that are too wide or too messy
Just because Excel can connect does not mean the workbook should receive raw operational tables.
Mistake 2: Rebuilding manual exports even though refresh is needed
If the same workbook is recreated every week, a database connection is often better.
Mistake 3: Ignoring security and credential ownership
A workbook with an external connection is also a connection management problem, not just a spreadsheet.
Mistake 4: Assuming the workbook should load everything
Excel should usually receive only the rows and columns the business actually needs.
Mistake 5: Forgetting that some connectors need drivers
Modern menus help, but some database types still require extra components in the environment. citeturn963468view0
A practical connection workflow
If you want a strong Excel-to-database setup, this is a good process.
Step 1: Choose the right source object
Decide whether the workbook should connect to:
- a table
- a view
- or a native SQL query
Step 2: Use the modern Get Data path
For most users, go through:
- Data
- Get Data
- From Database
- choose the correct database type
Step 3: Test a small pull first
Confirm:
- columns
- row counts
- data types
- credentials
- refresh behavior
Step 4: Shape the data in Power Query if needed
Rename columns, set types, filter rows, and remove unnecessary fields before loading.
Step 5: Configure refresh and connection behavior
Check how the workbook should update and who will maintain the connection.
FAQ
Can Excel connect directly to a database?
Yes. Excel can connect directly to databases through Data > Get Data using supported database connectors, and it can also use legacy Microsoft Query and certain ODBC-style workflows in some environments.
What is the best way to connect Excel to SQL Server?
For most modern workflows, the best way is to use Data > Get Data > From Database > From SQL Server Database, then choose the table, view, or SQL query you want and load or transform the data with Power Query.
Can I refresh database data in Excel?
Yes. Excel supports refreshable external data connections, and you can refresh manually or configure certain connection properties such as refresh on open depending on the workbook and connection type.
Should I connect Excel to raw tables or use a query?
That depends on the workflow. For simple exploration, loading a table or view can be fine. For cleaner and more controlled reporting, using a curated view or a native SQL query is often the better option.
Final thoughts
Connecting Excel to a database is not only about making the connection succeed.
It is about building a workbook that stays useful after the connection succeeds.
The strongest setups usually use the modern Get Data workflow, keep source logic in the database where it belongs, shape the result with Power Query only where needed, and treat refresh, credentials, and source design as part of the workflow instead of afterthoughts.
That is what turns an Excel workbook from a file with pasted data into a repeatable reporting tool.