Dashes in Dataname

  • I am trying to construct a SQL statement as follows:

        SELECT Dataname-1, Dataname-2, Dataname-3 FROM FILE1

    The dashes are presenting a problem.  Is there a way around this or must I change the data names on the server?  any help would be appreciated.

    Thanks,

    charlie

  • Try bracketing [ ]  like [Dataname-1]

    -Sharon

  • Thanks Sharon....

  • If your field name has spaces, you would use bracketing as well like FIRST NAME would be [FIRST NAME]

  • If you have any control over the back-end, a far better solution is to adopt a good naming convention for all objects, tables, fields, etc.

    Remove all spaces in names.

    Use the CamelBack style of names, in which the first letter of each word in the object name is capitalized.

    Don't use non-alphabetic characters, such as the dash, in object names.

    While it is still a good practice to use brackets around names in your SQL statements, you'll find that a good naming convention will eliminate a lot of nagging little issues like the one about which you're asking.

     

     

  • If you are renaming them (a real pain), underscores (_) will also work as a replacement for dashes with no problems.  I've used both 'CamelBack' and underscores and I think it's a matter of personal preference.

    Steve

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

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