Please help with brackets []

  • Hi,

    I'm sure this one's really easy for you but I really don't know how to change this behaviour.

    I have a table called 631586971108797504 and what I want to do is select all data from it.

    I entered in Query Analyzer:

    Select * from [dbo.631586971108797504]

    All I get as result is this error message:

    Nachr.-Nr. 208, Schweregrad 16, Status 1, Zeile 1

    Ungültiger Objektname 'dbo.631586971108797504'.

    In short object unknown.

    I'm sure I selected the correct database in Query Analyzer. There was no spelling mistake as I used the object browser tp drag the table name into the statement. I also tried a different table from the same database where you do not have to use []:

    select * from dbo.tb_Formeln

    This statement works perfectly as long as I do not alter it to:

    select * from [dbo.tb_Formeln]

    which as I understood normally wouldn't hurt.

    Is there maybe an option I have to set or reset to get my query work?

    Answers will be really appreciated....

    Thanks in advance

    Astrid

  • Select * from dbo[.631586971108797504]

     

    The brackets are around the object name. dbo is the schema. I use this when someone names a column "name" or "description" or some other reserverd word.

     

    select a.[name]

     from mytable a

     

  • Hi Steve,

    thanks so much. That's it.

    Really didn't see the forest among all those trees.

    You saved my evening.

    Bye

    Astrid

  • Steve's solution may not actually work...I believe the first bracket has to be after the period.

    So:

    Select * from dbo[.631586971108797504]

    should really be:

    Select * from dbo.[631586971108797504]

    I know it's just symantics and his explanation really showed the correct way, but someone reading this post might not pay attention to the explanation and wonder why it failed.

    -SQLBill

  • yes, correct!!!

    Fingers moving a bit more quickly than the mind

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

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