Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Pass-Through Query Syntax Error

Pass-Through Query Syntax Error

Pass-Through Query Syntax Error

Trying to learn to do a pass-through query with the following but I am getting syntax error trying to get data from a table called dbo.Sales Invoices from our SQL Server.

SELECT dbo.Sales Invoices.SalesInvoiceID, dbo.Sales Invoices.SalesInvoiceDate
FROM dbo.Sales Invoices;

ODBC---call failed.
[Micosoft][ODBC SQL Server Driver][SQL Server]Lne 1: Incorrect syntax near ‘,’,(#170)

Could anyone let me know what I am doing wrong?


RE: Pass-Through Query Syntax Error

A good reminder to use a naming convention that doesn't allow special characters or spaces.

Hook'D on Access
MS Access MVP

RE: Pass-Through Query Syntax Error

Thanks PHV and Duane,
I figured it had to be the space in the table name. Unfortunately, this an old access table created and upsized to SQL server before my time. I was asked for a solution to speed up a the printing of a Sales Invoice report which uses a query with 6 tables linked via ODBC. It is taking approximately 5 minutes to generate this invoice as it's pulling to many records from these 6 tables from SQL Server through the network to the users desktop for processing. I am not a SQL Server programmer nor have ever used T-SQL Pass-Through Query before so I am a newbie at this. I am still learning about the SQL Server syntax so still need to get my head around this and don't have a clue where to put these single quotes.

I am able to create a pass-through for this with no problem.

SELECT dbo.Companies.Name, dbo.Companies.Address1
FROM dbo.Companies;

But still can't get this to work without the syntax error showing up

SELECT dbo.Sales Invoices.SalesInvoiceNo, dbo.Sales Invoices.SalesInvoiceDate
FROM dbo.Sales Invoices;

RE: Pass-Through Query Syntax Error


2nd and 3rd one worked for me.
Although, I am still confused with single quotes and brackets, thought these were only Access properties and not T-SQL properties. Seems I still have a long way too go with learning this.

Thank you very much again for your assistance...

RE: Pass-Through Query Syntax Error

Congrats on testing the waters by using pass-through queries. You will find them very efficient for reporting and other purposes. The records pulled using a p-t are not editable.

Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close