Wednesday, March 7, 2012

Enterprise Manager error when using WITH (NOLOCKS)

I have added WITH (NOLOCK) to a couple of views that were causing unecessary
blocking for MS Access end user reporting.
I can update edit and save the views fine with Query Analyzer, however when
I try and run the query from Enterprise Manager Design View I get this
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect Syntax
The views work fine in everywhere else. When in EM if I remove the WITH
(NOLOCK) I do not get the error.
It looks as if the alias is causing the issue.
select * from MyTable WITH (NOLOCK) works
however Select * from MyTable mt WITH (NOLOCK) causes the error. But only in
EM not in query analyzer.
Is anyone else experiencing this?
"lurdan" wrote:

> I have added WITH (NOLOCK) to a couple of views that were causing unecessary
> blocking for MS Access end user reporting.
> I can update edit and save the views fine with Query Analyzer, however when
> I try and run the query from Enterprise Manager Design View I get this
> [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect Syntax
> The views work fine in everywhere else. When in EM if I remove the WITH
> (NOLOCK) I do not get the error.
>
|||I got the same result. When I tried to run the query in EM, the query tool
inverted the alias to after the table hint, which is bad syntax.
Russel Loski, MCSD.Net
"lurdan" wrote:
[vbcol=seagreen]
> It looks as if the alias is causing the issue.
> select * from MyTable WITH (NOLOCK) works
> however Select * from MyTable mt WITH (NOLOCK) causes the error. But only in
> EM not in query analyzer.
> Is anyone else experiencing this?
> "lurdan" wrote:

No comments:

Post a Comment