Strange SSMS Behaviour

  • I've managed to fix this but I really would like to know what was going on

    I had a very simple update query of the form:

    update a

    set a.col2 = b.col2

    from server.db.dbo.table1 a

    inner join dbo.table2 b

    on a.col1 = b.col1

    Which kept giving the error:

    Msg 102, Level 15, State 1, Line 4

    Incorrect syntax near ' '

    To fix it I had to remove all leading white space from the query.

    Adding the spaces back in to fix the readability didn't break it again.

    So what the hell was going on?

  • If you still have the query that was causing the error, paste the text into something like Notepad++, then go to view->Show Symbol->Show All Characters.

    I'm guessing that there's some strange character in there that can't be displayed by the SSMS GUI.

  • Thanks for that...

    I found this:

    select 'weird', ascii(' ')

    union all

    select 'space',ascii(' ')

    returned:

    weird160

    space 32

    So it was a stray ascii 160 character which had somehow got in there.

  • 160 is a non-breaking space.

    You very often get such characters if you copy and paste text from the web.

  • Stefan_G (8/25/2010)


    160 is a non-breaking space.

    You very often get such characters if you copy and paste text from the web.

    I had copied other queries in the same query window from my onenote project which might have introduced certain web attributes.

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

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