Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    205

    Unanswered: Square brackets in SQL Server

    Hi

    Do i have use square brackets surrounding the table names when executing a query in SQL Server ? i.e Is

    select * from Department

    different from

    select * from [Department]

    I'm using a case-insensitive SQL Server installation. Any help is appreciated!

    Thanks in advance,
    Sam

  2. #2
    Join Date
    Oct 2004
    Location
    Durban - South Africa
    Posts
    13
    No, this is only necessary when the table name contains a space for example

    Code:
    select *
    from [Department Managers]
    Another time when [] are required is when a column or table name is the name of a built in SQL Server function or keyword for example, if you column is called from, this must be accessed like

    Code:
     
    Select [From],[To]
    from tbl
    The fact that it is a case sensitive installation has nothing to do with it.
    Hope this helps.
    TrevorW
    If at first you don't succeed, call it version 1.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •