SQL Server Performance

Table with '-' in the name of the table

Discussion in 'Getting Started' started by ashish.johri, Sep 12, 2008.

  1. ashish.johri New Member

    I have found one table in the database when I expanded this in the management studio. The name of the table has '-' in it. For example the name of the table is Tbl-2005-Ashish. This contains 3000 rows. Amazingly when I try following command this gives error.
    select count (*) from Tbl-2005-Ashish
    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near '-'.
    Could you please tell me what is missing here?
    Also If I try following command:
    create table Tbl-2005-Ashish(test1 int)
    Error is as follows:
    Please let me know how this table got created.
  2. simondm New Member

    select count(*) from [tbl-2005-ashish]
  3. Madhivanan Moderator

    Always use underscore _ in place of space or hyphen which is more readable and error free
  4. ashish.johri New Member

    Thanks sir for your quick response

Share This Page