what''s wrong with simple statement?

  • EXEC ('SELECT ' + @ReverseFields + ' = COUNT(ItemID) FROM biditems where EventID in (' + @EventID + ')')

    I get:

    Server: Msg 170, Level 15, State 1, Line 1

    Line 1: Incorrect syntax near '='.

    Server: Msg 170, Level 15, State 1, Line 5

    Line 5: Incorrect syntax near ')'.

    Server: Msg 170, Level 15, State 1, Line 5

    Line 5: Incorrect syntax near ')'.

    Why is this hapenning?

  • Its likely in the @ReversFields parameter.

    Try to do a Print 'SELECT ' + @ReverseFields + ' = COUNT(ItemID) FROM biditems where EventID in (' + @EventID + ')'

    and see what it shows you, is it a valid query? I think part of it is the = COUNT(ItemID)

  • How many columns are in your @ReverseFields?  I think you would need to set each individually = to COUNT (if there is more than 1 column)....



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Sorry... there was not suppose to be COUNT

    tring is like this:

    EXEC ('SELECT ' + @ReverseFields + ' = ItemID FROM biditems where EventID in (' + @EventID + ')')

  • doesn't matter

    what are you trying to do?

    what is the value of the @ReverseFields?

    Replace the exec with a PRINT and what is output in the messages window?

    You need to see what it is trying to execute so you can see what is wrong with it.

    I'm still sure its because you have = ITEMID something is not properly formatted here.

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply