SELECT fields with a space in the name

  • How do I Select a Field in SQL whose name has spaces?

    Field: STR89 Type

    Table (FROM): TRUS

    Thanks

    Regards

  • SELECT [column name with spaces in it] AS SensibleAlias FROM table

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Qui-Gon Jinn!

  • Square brackets, as Gail told you, are always a safe way to refer to fields, even if you don't have spaces. Some languages also have accent marks, which can raise similar havoc - brackets help there as well. I deal with the issue occasionally in the Czech Republic, working on other people's databases. Best advice is to avoid both if at all possible, and stick to the standard Latin 26, or 36, if you like including numerals.

  • Thanks!

    I deal with the issue occasionally in the Czech Republic

    I deal with it to here in Portugal.

    Regards

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

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