0

The following query results in an error with the following message:

Incorrect syntax near the keyword 'for'. How should I get around this error...

I think in the query below SQL Server does not like the "@" sign.....

Any thoughts? Thanks!!!

Declare ObsSet_Cursor for 
 Select o.EventSetName,
        o.EventSetDisplay, 
        o.EventSetDescription, 
        o.ChildSetName
  From   ##Final f, 
         ##ObsSetLevel o
  Where  f.ChildSetName = o.EventSetName and 
         f.ChildSetName = @str 
1
  • OK, this code has so many sql antipatterns. First, do not use cursors if a set-based alternative exists which they do over 90% of teh time. Next, implicit joins are very bad and there is noexcuse for writing them inteh 21st century. Finally global temp tables can create problems as they are visible to other seessions (and not just the ones you intended). Do not use them unless you have no other choice. Commented Aug 13, 2013 at 20:18

1 Answer 1

1

You missed cursor keyword:

Declare ObsSet_Cursor cursor for ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.