Our team was manually exporting and re-entering data between Access and Outlook every single day. Their VBA programmer automated the entire workflow in about two weeks. We got back roughly 8 hours a week almost immediately.
Microsoft Access Services
Excel SQL Database Integration: Connect Excel to SQL Server, MySQL and PostgreSQL
Stop exporting CSV files from your database and cleaning them in Excel. We connect Excel directly to SQL Server, MySQL, PostgreSQL and Oracle with Power Query, ODBC and VBA, so reports refresh from the source, with secure access and fast queries. Fixed-scope projects from $1,200.
We had them do a complete rewrite of an Excel spreadsheet that locked up computers, when it was executed. Rajan did a good job of rewriting the spreadsheet and speeding it up. it takes three seconds to refresh compared to 20 minutes it was taking earlier. We'll definitely use Rajan and his team in the future.
What Is Excel SQL Database Integration?
Excel SQL database integration connects a workbook directly to a database such as SQL Server, MySQL, PostgreSQL or Oracle, so Excel pulls the data itself instead of someone exporting and pasting it. The connection is built with Power Query, an ODBC or OLE DB driver, or VBA with ADO. Each refresh runs a saved query against the source, which keeps reports consistent and removes copy-and-paste errors.
Databases: SQL Server, Azure SQL, MySQL, PostgreSQL, Oracle and anything with an ODBC or OLE DB driver.
Tools: Power Query (Get Data), ODBC and OLE DB connections, the Data Model, and VBA with ADO.
Refresh: on file open, on a timer, by button or macro, or scheduled outside Excel.
Security: Windows Authentication, read-only logins, access to views instead of base tables, encrypted connections.
Pricing: fixed-scope quote after a free review. Projects typically start at $1,200.
How to Connect Excel to a SQL Database (Step by Step)
This is the fastest way to connect Excel to SQL Server with no code. The same Get Data menu also offers MySQL, PostgreSQL and Oracle connectors, plus generic ODBC and OLE DB options for other databases.
- Open the SQL Server connector. In Excel, go to Data > Get Data > From Database > From SQL Server Database.
- Enter the server and database. Type the server name (for example SQLPROD01 or SQLPROD01\SQLEXPRESS) and, optionally, the database name. Leave Import selected.
- Choose authentication. Use Windows authentication when your domain account has access, or Database authentication with a read-only SQL login. Accept the encrypted connection prompt.
- Select a table or view. In the Navigator, choose the table or view, preferably a reporting view, then select Transform Data to filter columns and rows or Load to import it.
- Set the refresh behavior. Open Data > Queries & Connections, right-click the query, choose Properties, and enable Refresh data when opening the file or Refresh every N minutes.
That gets a table into Excel. For a report people rely on, we go further: connect to a purpose-built SQL view, filter on the server with a parameter, and load only the columns you need. In Power Query M that looks like this:
let
// StartDate is a Power Query parameter (Home > Manage Parameters)
Source = Sql.Database("SQLPROD01", "Sales", [CommandTimeout = #duration(0, 0, 5, 0)]),
Orders = Source{[Schema = "dbo", Item = "vw_OrdersForExcel"]}[Data],
// This filter folds to a WHERE clause, so SQL Server does the work, not Excel
Filtered = Table.SelectRows(Orders, each [OrderDate] >= StartDate),
Selected = Table.SelectColumns(Filtered, {"OrderID", "OrderDate", "CustomerName", "Total"})
in
SelectedBecause the filter folds back to SQL Server as a WHERE clause, Excel downloads only the rows it needs and refreshes stay fast even on large tables.
Power Query vs ODBC vs VBA: Which Connection Method Should You Use?
| Method | Code required | Best for | Limits |
|---|---|---|---|
| Power Query (Get Data > From Database) | No (M for advanced cases) | Refreshable reports, filtering, joins and cleanup, with query folding to the server | Read-only; MySQL, PostgreSQL and Oracle connectors need a client component installed |
| ODBC / OLE DB connection (Get Data > From ODBC or OLE DB) | No | Databases without a native Excel connector, or an existing DSN | Driver and DSN must match Excel's 32-bit or 64-bit version on every PC |
| VBA + ADO | Yes | Parameter forms, refresh buttons, multi-step logic and write-back via stored procedures | Must be maintained as code; handle errors, timeouts and security carefully |
| Data Model / Power Pivot | No (DAX for measures) | Millions of rows, relationships and PivotTables beyond the 1,048,576-row worksheet limit | Import snapshot, not a live query |
| Power BI or a SQL reporting view | No / light | Near-real-time dashboards, many viewers, scheduled refresh | A separate tool and license to govern |
Example: parameterized SQL query from Excel VBA
When users need date pickers, a refresh button or write-back, we use ADO with parameters. Parameters prevent SQL injection and let SQL Server reuse execution plans. This version uses Windows Authentication, an encrypted connection and guaranteed cleanup:
Option Explicit
' Pulls parameterized SQL Server data into the "Data" sheet.
' Uses late binding, so no extra VBA references are required.
' Requires Microsoft ODBC Driver 17 or 18 for SQL Server on the user's PC.
Public Sub RefreshSalesFromSql()
Dim cn As Object, cmd As Object, rs As Object
Dim ws As Worksheet, i As Long
Dim startDate As Date, endDate As Date
Set ws = ThisWorkbook.Worksheets("Data")
startDate = ThisWorkbook.Worksheets("Controls").Range("StartDate").Value
endDate = ThisWorkbook.Worksheets("Controls").Range("EndDate").Value
On Error GoTo Fail
Application.ScreenUpdating = False
Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = "Driver={ODBC Driver 18 for SQL Server};" & _
"Server=SQLPROD01;Database=Sales;Trusted_Connection=Yes;" & _
"Encrypt=Yes;TrustServerCertificate=No;"
cn.CommandTimeout = 120
cn.Open
Set cmd = CreateObject("ADODB.Command")
With cmd
.ActiveConnection = cn
.CommandType = 1 ' adCmdText
.CommandText = "SELECT OrderID, OrderDate, CustomerName, Total " & _
"FROM dbo.vw_OrdersForExcel WHERE OrderDate >= ? AND OrderDate < ?"
.Parameters.Append .CreateParameter("startDate", 135, 1, , startDate) ' adDBTimeStamp, adParamInput
.Parameters.Append .CreateParameter("endDate", 135, 1, , endDate)
Set rs = .Execute
End With
ws.Rows("2:" & ws.Rows.Count).ClearContents
For i = 0 To rs.Fields.Count - 1
ws.Cells(1, i + 1).Value = rs.Fields(i).Name
Next i
ws.Range("A2").CopyFromRecordset rs
Cleanup:
On Error Resume Next
If Not rs Is Nothing Then rs.Close
If Not cn Is Nothing Then cn.Close
Application.ScreenUpdating = True
Exit Sub
Fail:
MsgBox "SQL refresh failed: " & Err.Description, vbExclamation
Resume Cleanup
End SubConnecting Excel to SQL Server, MySQL, PostgreSQL and Oracle
| Database | Connector | What must be installed | Typical authentication |
|---|---|---|---|
| SQL Server / Azure SQL | Built-in SQL Server connector | Nothing for Excel Power Query; ODBC Driver 17/18 for VBA and ADO | Windows (Kerberos) or SQL login; Microsoft Entra ID for Azure SQL |
| MySQL | MySQL database connector or ODBC | MySQL Connector/NET or MySQL ODBC driver | MySQL user and password with SSL |
| PostgreSQL | PostgreSQL database connector or ODBC | Npgsql provider or PostgreSQL ODBC driver | Database user and password with SSL |
| Oracle | Oracle database connector or ODBC | Oracle client software matching Excel's bitness | Oracle user and password or wallet |
| Other (Snowflake, Redshift, SAP HANA, etc.) | ODBC or vendor connector | Vendor ODBC driver | Per vendor |
Common Excel SQL Integration Use Cases
Finance: transaction, AR/AP and general ledger extracts that refresh for month-end instead of being rebuilt.
Sales: territory, pipeline and quota reports from a CRM or order database.
Operations: inventory, production and fulfillment tracking from an ERP or warehouse system.
Management: self-service dashboards so leaders do not wait on IT for each new export.
Analysts: ad-hoc queries run safely inside Excel against approved views.
Compliance: reports that always run the same approved query, with a clear source of truth for auditors.
Common Excel to SQL Connection Errors and How We Fix Them
| Error or symptom | Usual cause | Fix |
|---|---|---|
| A network-related or instance-specific error occurred | Wrong server or instance name, firewall, SQL Browser or TCP/IP disabled, or VPN not connected | Verify the server\instance name and port, open the firewall, enable TCP/IP, connect to VPN |
| Login failed for user | Wrong credentials, no database permission, or Excel saved old credentials | Clear saved credentials in Data > Get Data > Data Source Settings and grant the login access to the database or view |
| Data source name not found and no default driver specified | ODBC DSN or driver missing, or 32-bit vs 64-bit mismatch with Excel | Install the driver matching Excel's bitness and create the DSN in the matching ODBC Administrator |
| Formula.Firewall: Query references other queries or steps | Privacy levels block combining data from different sources | Set privacy levels correctly or restructure the queries so the sources are not mixed in one step |
| Refresh takes minutes or times out | Whole tables pulled, query folding broken, missing indexes, huge row counts | Use filtered views, push logic to SQL, add indexes, load to the Data Model, raise CommandTimeout only as a last step |
| The workbook shows 1,048,576 rows and stops | Worksheet row limit reached | Load to the Data Model or aggregate in SQL before loading |
Why Choose Us for Excel SQL Integration?
We work on both sides of the connection: the Excel workbook and the database behind it.
Refreshable, Reliable Reports
Power Query and VBA connections that refresh on open, on a timer or on demand, built so one failed refresh never overwrites good data.
Secure by Design
Windows Authentication, read-only logins, access to views rather than base tables, encrypted connections, and no passwords in connection strings.
Fast on Large Data
Query folding, indexing recommendations and Data Model loading keep refreshes quick even when tables run to millions of rows.
Right Tool for Each Job
Power Query, ODBC, OLE DB, ADO and VBA. We recommend what is easiest to maintain for your team, not what is trendiest.
What's Included in Our Excel SQL Integration Services
Requirements analysis: data sources, refresh frequency, users and security needs
Database connectivity setup and testing, including ODBC and OLE DB drivers
Power Query connections with query folding and parameters
Purpose-built SQL views or stored procedures for reporting
VBA and ADO automation for parameter forms, refresh buttons and controlled write-back
Query optimization and indexing recommendations
Scheduled and on-open refresh automation
Data transformation, cleaning and validation logic
Error handling, connection recovery and refresh logging
Access control, documentation, user training and ongoing support
Our Excel SQL Integration Process
A fixed-scope path from requirements to a fast, secure, documented connection.
1. Requirements and Free Review
We identify the data you need, refresh frequency, users, database platform and security rules, then confirm the approach and quote.
2. Connection Setup
We configure drivers, secure authentication and permissions, and test the connection from the actual user machines.
3. Query Development
We write optimized SQL or views, add parameters and filters, and design transformations that fold back to the server.
4. Excel Build
We build Power Query connections, VBA automation, refresh controls, PivotTables and dashboards.
5. Testing and Optimization
We reconcile Excel totals to the database, test failure cases, and benchmark and tune refresh times.
6. Deployment and Training
We deploy to production, train your users, deliver documentation, and set up support.
How Much Does Excel SQL Database Integration Cost?
Projects typically start at $1,200 and are quoted as a fixed scope after a free review. The main cost drivers are the number of data sources and reports, query complexity, whether you need write-back to the database, refresh automation, and how many users and machines must be set up. You approve a written scope and price before work begins.
Is Excel still the right tool?
Sometimes the better answer is to move the data itself. If several people edit the same workbook or the file keeps growing, consider moving the workbook to a database. If your data lives in Access, you can move the tables to SQL Server and keep the Access screens, then point Excel at the same SQL Server. We will tell you honestly which route fits during the free review. If your source is an application rather than a database, see our API integration with MS Access and Excel service.
FAQ
Frequently Asked Questions
Find answers to common questions about our services
Ready to Connect Excel to Your SQL Database?
Send us your project details through the RFQ form. Tell us which database and reports you need and we will respond with a detailed proposal and estimate promptly.
Prefer to talk? Call us at +1 385 386 3860
Last updated: October 6, 2026. Reviewed by the Excel Access Expert engineering team.