Office Compatibility Issues

Fix Access Syntax Errors with SQL Server Stored Procedures

John WilsonJohn Wilson Nov 20, 2026 869 views

Question details

The user needs to run a SQL Server stored procedure from Microsoft Access without SQL syntax or conversion errors.

Fix Access Syntax Errors with SQL Server Stored Procedures
Product
Microsoft Access and SQL Server
Device & OS
not provided
Scenario
An Access database needs to use results from a SQL Server procedure containing T-SQL constructs and UNION queries.
Observed behavior
Access reports syntax or conversion errors when SQL Server T-SQL is used in an Access query.
Before you start

Confirm that you can connect to the SQL Server database and have permission to execute the stored procedure. Have the procedure name, required parameters, and an ODBC data source name (DSN) ready.

Solution 1Recommended

Call the stored procedure through an Access pass-through query

Use a pass-through query to send T-SQL directly to SQL Server instead of having Access interpret it.

1
Test the procedure in SQL Server

In SQL Server Management Studio, connect to the database and execute the procedure with valid parameters, for example: EXEC dbo.MyWorkQuery '2018-05-15', '2018-05-16'.

2
Create a pass-through query

In Access, open the ACCDB file and select Create > Query Design. Close the table-selection dialog, then choose Pass-Through on the query design ribbon.

3
Configure the connection

Open the query's Property Sheet and set ODBC Connect Str to a valid connection string using your SQL Server DSN and authentication method. Set Returns Records to Yes if the procedure returns a result set.

4
Enter and run the call

In the query's SQL view, enter the tested EXEC statement, then select Run. Save the query and use it as a record source for an Access report or from VBA.

Call the stored procedure through an Access pass-through query
Why pass-through works: SQL Server processes the procedure's T-SQL, including its CTEs, CASE expressions, and CAST functions. Access does not need to convert that code into the ACE SQL dialect.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative for working with documents, spreadsheets, and presentations. Its familiar interface and support for common Microsoft Office formats make it easy to move existing files into your workflow. It does not fix Access queries or replace the SQL Server pass-through connection.

Open and edit Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXWork with spreadsheet data and reports alongside your database workflowUse a familiar interface for a smoother move from Microsoft OfficeInstall a lightweight office suite for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does T-SQL fail in a regular Access query?

Access uses the ACE SQL dialect, which differs from SQL Server T-SQL. Create a pass-through query to send SQL Server-specific syntax directly to the server.

How do I connect an Access pass-through query to SQL Server?

Open the pass-through query's Property Sheet and enter a valid SQL Server ODBC connection string in ODBC Connect Str. The connection can use a configured DSN.

What should I check if a UNION query returns an error?

Run each SELECT separately in SQL Server Management Studio. Each branch must return the same number of columns, in matching order, with compatible data types.

Can an Access report use a stored procedure's results?

Yes. If the procedure returns a suitable result set, set the pass-through query's Returns Records property to Yes, save the query, and select it as the report's record source.