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.

Value-basedFixed-Scope Projects

Call us at +1 (385) 386-3860

Verified client

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.

Verified client

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.

1 / 4

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.

  1. Open the SQL Server connector. In Excel, go to Data > Get Data > From Database > From SQL Server Database.
  2. Enter the server and database. Type the server name (for example SQLPROD01 or SQLPROD01\SQLEXPRESS) and, optionally, the database name. Leave Import selected.
  3. 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.
  4. 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.
  5. 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
    Selected

Because 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?

Ways to connect Excel to a SQL database
MethodCode requiredBest forLimits
Power Query (Get Data > From Database)No (M for advanced cases)Refreshable reports, filtering, joins and cleanup, with query folding to the serverRead-only; MySQL, PostgreSQL and Oracle connectors need a client component installed
ODBC / OLE DB connection (Get Data > From ODBC or OLE DB)NoDatabases without a native Excel connector, or an existing DSNDriver and DSN must match Excel's 32-bit or 64-bit version on every PC
VBA + ADOYesParameter forms, refresh buttons, multi-step logic and write-back via stored proceduresMust be maintained as code; handle errors, timeouts and security carefully
Data Model / Power PivotNo (DAX for measures)Millions of rows, relationships and PivotTables beyond the 1,048,576-row worksheet limitImport snapshot, not a live query
Power BI or a SQL reporting viewNo / lightNear-real-time dashboards, many viewers, scheduled refreshA 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 Sub

Connecting Excel to SQL Server, MySQL, PostgreSQL and Oracle

Database connection requirements for Excel
DatabaseConnectorWhat must be installedTypical authentication
SQL Server / Azure SQLBuilt-in SQL Server connectorNothing for Excel Power Query; ODBC Driver 17/18 for VBA and ADOWindows (Kerberos) or SQL login; Microsoft Entra ID for Azure SQL
MySQLMySQL database connector or ODBCMySQL Connector/NET or MySQL ODBC driverMySQL user and password with SSL
PostgreSQLPostgreSQL database connector or ODBCNpgsql provider or PostgreSQL ODBC driverDatabase user and password with SSL
OracleOracle database connector or ODBCOracle client software matching Excel's bitnessOracle user and password or wallet
Other (Snowflake, Redshift, SAP HANA, etc.)ODBC or vendor connectorVendor ODBC driverPer 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

Frequent Excel SQL connection problems
Error or symptomUsual causeFix
A network-related or instance-specific error occurredWrong server or instance name, firewall, SQL Browser or TCP/IP disabled, or VPN not connectedVerify the server\instance name and port, open the firewall, enable TCP/IP, connect to VPN
Login failed for userWrong credentials, no database permission, or Excel saved old credentialsClear 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 specifiedODBC DSN or driver missing, or 32-bit vs 64-bit mismatch with ExcelInstall the driver matching Excel's bitness and create the DSN in the matching ODBC Administrator
Formula.Firewall: Query references other queries or stepsPrivacy levels block combining data from different sourcesSet privacy levels correctly or restructure the queries so the sources are not mixed in one step
Refresh takes minutes or times outWhole tables pulled, query folding broken, missing indexes, huge row countsUse 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 stopsWorksheet row limit reachedLoad 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.

01

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.

02

2. Connection Setup

We configure drivers, secure authentication and permissions, and test the connection from the actual user machines.

03

3. Query Development

We write optimized SQL or views, add parameters and filters, and design transformations that fold back to the server.

04

4. Excel Build

We build Power Query connections, VBA automation, refresh controls, PivotTables and dashboards.

05

5. Testing and Optimization

We reconcile Excel totals to the database, test failure cases, and benchmark and tune refresh times.

06

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

In Excel, go to Data > Get Data > From Database > From SQL Server Database, enter the server and database name, choose Windows or Database authentication, pick the table or view in the Navigator, and select Load or Transform Data. Excel stores the connection so you can refresh it later. For anything beyond a simple table pull, we add filtered views, parameters and refresh automation.

Yes. Excel's Get Data > From Database menu includes MySQL, PostgreSQL and Oracle connectors, but each needs a client component installed first (MySQL Connector/NET, the Npgsql provider and Oracle client software respectively). Any database with an ODBC or OLE DB driver can also be reached through Get Data > From ODBC or From OLE DB, or through VBA and ADO.

Not strictly. Excel pulls a snapshot each time the connection refreshes, so the data is as current as your last refresh. You can refresh on file open, on a timer while the workbook is open, or with a button or VBA macro. For near-real-time dashboards or very large datasets, we move the reporting layer to Power BI or a SQL view designed for reporting.

The connection definition is saved in the workbook, so it works the next time anyone with SQL access opens the file. Excel itself must be open to refresh, so we set the workbook to refresh on open, or schedule the refresh outside Excel when you need unattended updates.

Yes, with VBA and ADO calling stored procedures, or with Power Automate. Excel's built-in Power Query connections are read-only. We write back through parameterized stored procedures with validation, never by giving users direct table write access.

The usual causes are pulling whole tables instead of filtered views, transformations that stop query folding so Excel does the work instead of the server, missing indexes, and loading millions of rows into worksheets. We push filters and joins to SQL Server, add indexes where justified, load large results to the Data Model, and benchmark refresh times before handover.

It is when set up correctly. We use Windows Authentication where possible, grant a read-only account access to specific views rather than base tables, use encrypted connections, and keep passwords out of workbook connection strings. Users only see the data their role allows.

We quote fixed-scope projects based on the business value delivered, and projects typically start at $1,200. After a free review you receive a written scope and a fixed quote, not an open-ended hourly bill. Cost depends mainly on the number of data sources and reports, the complexity of the queries, whether you need write-back, and refresh automation requirements.

Yes. We provide documentation and handover with every project, plus optional support for query tuning, connection troubleshooting after server or driver changes, and new reports.

Still have questions? Contact us or browse the full FAQ.

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.

1
15-min audit
→
2
Fixed-scope quote
→
3
Deliver outcome
15+Years Experience
FixedScope Quotes
2011Established

Prefer to talk? Call us at +1 385 386 3860

Last updated: October 6, 2026. Reviewed by the Excel Access Expert engineering team.

Related in this topic

Part of Integration services

Related services

Explore more solutions tailored to your business needs