The Column Synonym

  • Comments posted to this topic are about the item The Column Synonym

  • You CAN, however, create a simple "Pass through view" that will do the trick.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • You can also add a computed column to the table - but I really don't see the need or requirement to create a column with multiple names.  It is just as easy to alias a column in a query as it would be to use a view or computed column - which would just end up being even more confusing.

    Imagine a view is created - that references a computed column which only exists to give the column a different name - and aliases the computed column to the original column name.  And then, someone includes that aliased column in the WHERE clause...

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Jeffrey Williams wrote:

    You can also add a computed column to the table - but I really don't see the need or requirement to create a column with multiple names.  It is just as easy to alias a column in a query as it would be to use a view or computed column - which would just end up being even more confusing.

    Imagine a view is created - that references a computed column which only exists to give the column a different name - and aliases the computed column to the original column name.  And then, someone includes that aliased column in the WHERE clause...

    If you mean "use more than a 2 part naming convention", except for the system database, I avoid more than the 2 part naming convention at all costs because databases don't always stay in the same place.  I'd rather just change the target of a synonym or view than to try to find all the places in code (both SQL and Front End) that uses 3 or 4 part naming.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden wrote:

    Jeffrey Williams wrote:

    Imagine a view is created - that references a computed column which only exists to give the column a different name - and aliases the computed column to the original column name.  And then, someone includes that aliased column in the WHERE clause...

    If you mean "use more than a 2 part naming convention", except for the system database, I avoid more than the 2 part naming convention at all costs because databases don't always stay in the same place.  I'd rather just change the target of a synonym or view than to try to find all the places in code (both SQL and Front End) that uses 3 or 4 part naming.

    Not referring to 2 part naming or actual synonyms.  Was being a bit tongue in cheek - I don't see any value to a column synonym since you can add an alias to your query and return any column name as you want.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Jeffrey Williams wrote:

    Jeff Moden wrote:

    Jeffrey Williams wrote:

    Imagine a view is created - that references a computed column which only exists to give the column a different name - and aliases the computed column to the original column name.  And then, someone includes that aliased column in the WHERE clause...

    If you mean "use more than a 2 part naming convention", except for the system database, I avoid more than the 2 part naming convention at all costs because databases don't always stay in the same place.  I'd rather just change the target of a synonym or view than to try to find all the places in code (both SQL and Front End) that uses 3 or 4 part naming.

    Not referring to 2 part naming or actual synonyms.  Was being a bit tongue in cheek - I don't see any value to a column synonym since you can add an alias to your query and return any column name as you want.

    Ah... got it.  I use "Pass thru Views" in such a fashion for limit columns in the same or other databases for security and performance purposes.  Sure... go ahead and use "SELECT *" on that! 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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