Link to home
Start Free TrialLog in
Avatar of PatrickLabbett
PatrickLabbettFlag for United States of America

asked on

ADO error: Incorrect syntax near 'TABLOCKX'.

Microsoft Office 2010 using an .adp file to connect to a SQL Server 2008 R2.

When trying to make modifications (increasing column size, setting/removing PK's/identity) we randomly come across the following error:


ADO error: Incorrect syntax near 'TABLOCKX'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax.

This did not start occurring until these databases were moved from SQL Server 2005 (and upgraded using RESTORE) to SQL Server 2008
Avatar of lcohan
lcohan
Flag of Canada image

"This did not start occurring until these databases were moved from SQL Server 2005 (and upgraded using RESTORE) to SQL Server 2008"

Sorry to ask but are you sure? As far as I recall this was introduced since SQL 2005 where table hints require WITH in front of the TABLOCKX(or NOLOCK,...) or any other hint. This was a change since SQL 2000 to 2005.
Here's one link to support that but regardless - you must change your code to fix that syntax error as there is no workaround or "wrapper" that you could use as far as I'm aware:

http://blogs.imeta.co.uk/sgoodman/archive/2008/12/16/539.aspx
Avatar of PatrickLabbett

ASKER

We are using Access projects ( Somefile.adp) that connects to SQL Server 2008. This error occurs when using "Design view" and making changes (ranging from increasing the size of an nvarchar column or setting a identity/pk.) The error comes up when trying to save the change in Access.

We can't "change the code" as it's happening through the Access Design View interface.

We never saw anything related to TABLOCKX previous to moving the databases to SQL Server 2008. Databases that still reside on our SQL 2005 server are not experiencing this issue.
it's happening through the Access Design View interface.
Than consider using SSMS to make changes instead of MS Access.
Our staff are restricted to using Access as SSMS isn't necessary for their normal workflow, leaving the chore of our senior IT staff to resolve it. We are trying to avoid that timesink.
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Unfortunately, as mentioned, that isn't possible. These employees do not know SQL. It's outside their core ability, training, and workflow. This is why we need Access for them to make simple changes. I will continue to search for an answer.
Microsoft has replied with the following information:

http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/e07ee680-55fc-4d43-95b6-7696d16c714f/

Hi Patrick,

So, I was able to reproduce the error message you were seeing when trying to modify the design of your table in an ADP connected to SQL 2008:  "-Unable to modify table.  ADO error: Incorrect syntax near 'TABLOCKX'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax."

We have filed this issue and the developers will be continuing to investigate it.  At this point I would recommend continuing to use the workaround you currently have or giving users SQL management studio so they can make design changes directly in SQL Server.

Thanks,

Kirk

Kirk Beller

Microsoft Online Community Support
While this did not resolve the actual issue I was trying to fix, Microsoft has confirmed that it's an issue with their product so the only way to fix the issue (as opposed to working around it) is to wait for an update to their product line.
Since the chances MS will fix this in the near future if ever, you may want to consider changing the database compatibility level to 80 (SQL Server 2000, the last time this syntax was supported.  I have tested with this setting and it does work with the deprecated syntax.
I've regraded, and based on the "Grading Tips":

If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information, or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. (Note: The use of a C in a vindictive manner is likely to be changed by a Moderator.)

I have found the C grade to be the most appropriate since the answer did "lack finality or do not completely address the issue presented."
SouthMod,

Don't worry about the points awarded in this thread.  This is the first question the author has posted and I am sure with time he/she will get a better understanding of how it works here.  Sometimes educating users takes time.

Thanks,
Anthony