Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Incorrect Syntax Near... Fine in QA not in Access

Author  Topic 

mgraser
Starting Member

4 Posts

Posted - 2008-04-04 : 17:15:25
I created a couple of stored procedures. One of them (let's call it SP1) dumps information into a table and then calls another stored procedure (SP2) to put the info in a temp table in crosstab format. SP1 then displays the info from the temp table.

When I execute SP1 from Query Editor, everything works perfectly. No errors are returned and my data is displayed just as expected.

When I try to execute SP1 from MS Access's pass-through query, I get the following error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','.(#102)[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'A'(#102)

I've found that the error occurs when the SP2 is called from within SP1. If it's working fine in Query Editor, shouldn't it work from MS Access? Any insights?

mgraser
Starting Member

4 Posts

Posted - 2008-04-04 : 17:25:26
I originally posted this in the SQL 2005 forum, so re-reading this I realize it may be confusing. Just to clarify:

I created all of my queries as stored procedures in SQL 2005. Everything is executing great when running directly in SQL Server's Query Editor, but when I run it from MS Access, I get the error listed.
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2008-04-07 : 08:16:02
Can you print the code before it's being exscuted inside the SP....i.e with the variables filled in with real-life values?

Sounds like there is some dynamic SQL at play.
Are you passing in any variables with single quotes in the content?
Go to Top of Page
   

- Advertisement -