Field Alias

  • Is there a way to set a field alias when defining a table?

    Some developers prefer long field names for clarity, but out data is often exported to other formats, which can be problematic, in particular with the dbf format. The dbf format truncates the field name to 10 characters, which can often result in multiple fields with the same name.

    I know you can create queries that alias the field names, but how can you be consistent with this if you have many people doing this?

    So, is there a way to set a permanent field alias. on a table?

  • The only thing that comes to mind is a view..

    CEWII

  • I agree. Other than masking the columns behind a view, there's no real way to do this.

    BTW, that's by design. SQL Server is not meant to be the presentation layer. It's expected that presentation would be handled elsewhere.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • If that's the case, what would be the recommended way to indicate a set of "alias" field names to use for presentation, whether for exporting data, linking to Access databases, or similar processes.

    How could consistency be enforced across the database?

  • Documentation and discipline are about the only things that come to mind. I've never tried doing something like this nor heard of anyone doing it successfully.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Wow. That's disappointing.

    Tha

  • Actually though, that's what views are for. If you really don't want the internal's available, a view masks it perfectly. You could run into issues though if you see lots of views being joined together as if they were tables. They're not and it will make a difference in some instances.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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