What's going on here?

  • SQL 2008 R2

    In a database I can successfully run:

    select count(*) from dbo.Check_Transaction_Bill

    select count(*) from dbo.Check_Dimension

    but when I try

    select count(*) from dbo.Check_Transaction_invoice_split

    I get the error message

    Msg 208, Level 16, State 1, Line 1

    Invalid object name 'dbo.Check_'.

    I can get round this by using

    select count(*) from dbo.[Check_Transaction_invoice_split]

    but would really like to understand what's happening. Can anyone enlighten me?

    Thanks

    --
    Scott

  • There's a space in the object name. If you have spaces, or a variety of other characters, in the object name, you have to enclose it in square-brackets to let SQL Server know where the object name begins and ends.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks for the reply. I can confirm there are no spaces in the object name or in the SQL code I posted.

    --
    Scott

  • Then you don't have permissions.

    It might also be a case sensitive server and you're getting the case wrong.

  • Scott-144766 (5/18/2011)


    Thanks for the reply. I can confirm there are no spaces in the object name or in the SQL code I posted.

    This piece, as you posted it, has a space in it between the underscore and "Transaction": Check_Transaction_invoice_split

    It has that space both places you posted it, and the error message says it can't find the "Check_" object, which also indicates a space or other termination character (hard return, char(10), char(13), or a very few others), after the underscore.

    The fact that it works, per your post, when you enclose it in square-brackets, also supports the existence of a space or termination character.

    Double check that you don't have something that's showing as a space when you copy-and-paste into the forum. It may not be a space in your actual script, but it's showing as one in the forum, and SQL Server thinks it's a termination character.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I believe this is the character you have in between the _ and T. http://www.fileformat.info/info/unicode/char/1f/index.htm I can replicate it in a text editor via ALT+031.

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • Thanks to both of you. Despite me being adamant there were no spaces in my select statement or table names there is actually an invisible character after the _ in Check_Transaction, which I can only observe by cursoring through the text and seeing the cursor stopping for one character at that point. SSMS doesn't show the character, but I'll definitely remember this one if it ever happens again.

    --
    Scott

  • Makes sense. Glad we could help.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 8 posts - 1 through 7 (of 7 total)

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