📖 Introduction
In most organizations, Microsoft SQL Server, Excel, and Access are widely used for storing, analyzing, and managing data.
While SQL Server is perfect for large-scale enterprise data, Excel and Access are often used by business users for quick analysis, reporting, and data entry.
But what if you could connect Excel or Access directly to SQL Server — allowing you to query live data, import, export, and even automate updates?
In this article, you’ll learn:
How to import/export data between SQL Server, Excel, and Access
How to use Linked Servers and OLE DB connections
SQL examples for querying Excel and Access files directly
Common errors and troubleshooting tips
🧠 Why Integrate SQL Server with Excel and Access?
| Benefit | Description |
|---|
| Live data connection | Access or Excel can pull updated data directly from SQL Server. |
| Eliminate manual imports | No need to repeatedly export/import CSVs. |
| Centralized data management | SQL Server handles storage, while Excel/Access serve as front-end tools. |
| Enhanced reporting | Use Excel charts or Access forms on top of real-time SQL data. |
🧩 Method 1: Import or Export Data via SQL Server Management Studio (SSMS)
Step 1: Launch Import/Export Wizard
In SSMS, right-click your database → Tasks → Import Data or Export Data.
Step 2: Choose Data Source
For Excel: select Microsoft Excel
For Access: select Microsoft Access
For both, specify file path and version (e.g., Excel 2007–2016).
Step 3: Choose Destination
Select SQL Server Native Client or your current SQL Server connection.
Step 4: Select Tables / Worksheets
Choose the tables (or Excel sheets) you want to import/export.
Step 5: Run the Operation
Click Finish to start the transfer. You’ll see a progress summary once completed.
⚙️ Method 2: Query Excel Files Directly Using OPENROWSET
You can query Excel data directly from SQL Server using the OPENROWSET function.
Example: Read Data from an Excel Sheet
SELECT *
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\Data\Sales.xlsx;HDR=YES',
'SELECT * FROM [Sheet1$]'
);
🔸 Explanation
Microsoft.ACE.OLEDB.12.0 → Provider for Excel/Access
HDR=YES → First row contains column headers
[Sheet1$] → Refers to the worksheet name
📌 Note
If you get an error like “Ad Hoc Distributed Queries are disabled”, enable it:
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
⚙️ Method 3: Query Access Database Using OPENROWSET
SELECT *
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'C:\Data\CustomerData.accdb';'admin';'',
'SELECT * FROM Customers'
);
Example: Insert Access Data into SQL Server Table
INSERT INTO dbo.CustomerMaster (CustomerID, Name, City)
SELECT CustomerID, Name, City
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.12.0',
'C:\Data\CustomerData.accdb';'admin';'',
'SELECT * FROM Customers'
);
🧩 Method 4: Use Linked Server to Connect Excel or Access Permanently
If you regularly query the same Excel or Access file, you can create a Linked Server for permanent access.
Step 1: Create Linked Server for Excel
EXEC sp_addlinkedserver
@server = 'ExcelLink',
@srvproduct = 'Excel',
@provider = 'Microsoft.ACE.OLEDB.12.0',
@datasrc = 'C:\Data\Sales.xlsx',
@provstr = 'Excel 12.0;HDR=YES';
Step 2: Query Excel Data
SELECT * FROM OPENQUERY(ExcelLink, 'SELECT * FROM [Sheet1$]');
Step 3: Create Linked Server for Access
EXEC sp_addlinkedserver
@server = 'AccessLink',
@provider = 'Microsoft.ACE.OLEDB.12.0',
@srvproduct = 'Access',
@datasrc = 'C:\Data\CustomerData.accdb';
Step 4: Query Access Data
SELECT * FROM OPENQUERY(AccessLink, 'SELECT * FROM Customers');
🔐 Security Considerations
Avoid storing Excel/Access files in unsecured folders.
Use Windows Authentication where possible.
Limit access to linked servers and OPENROWSET features via role-based permissions.
Disable Ad Hoc Distributed Queries after use in production environments.
🧠 Common Errors and Fixes
| Error Message | Cause | Solution |
|---|
| “Microsoft.ACE.OLEDB.12.0 provider is not registered” | Provider missing | Install Microsoft Access Database Engine (Download link) |
| “Ad Hoc Distributed Queries are disabled” | Feature disabled | Enable using sp_configure |
| “Could not find installable ISAM” | Incorrect connection string | Check Excel/Access file version and provider string |
| “Access denied” | File permissions issue | Give read/write access to SQL Server service account |
⚡ Performance Tips
Keep Excel/Access files on the same server to reduce network latency.
Always close Excel files before querying them from SQL Server.
For large data imports, use the BULK INSERT or SQL Server Import/Export Wizard.
Convert Excel data into .CSV before importing for better performance.
🧾 Conclusion
Integrating SQL Server with Excel and Access makes it easier to manage hybrid data workflows — from business reporting to automated synchronization.
You can:
Import/export data using SSMS Wizard
Query Excel and Access directly with OPENROWSET
Set up Linked Servers for permanent connections
This integration enables teams to work efficiently without duplicating data or breaking data integrity between systems.