as is optional for alias

Answered as is optional for alias

  • Monday, January 14, 2013 6:52 AM
     
     

    Hi,

    "as" is optional ,so please tel me should i use it or not (keepting future in mind)

    becasue i have to use it throught the database.

    some body pointed out that one can save client side number of bytes .

    some body said it is good practice.

    yours sincerely.

All Replies

  • Monday, January 14, 2013 7:00 AM
     
     

    From my point of view you should use because it will clearly point out that paritcular is an alias..  Also on client side byte issue ....

    How many byte "as" will consume in a current technology era..??

    Thanks,

    Saurabh


    http://www.linkedin.com/profile/view?id=36482856&trk=tab_pro http://www.experts-exchange.com/M_6313078.html

  • Monday, January 14, 2013 7:12 AM
     
     

    "AS' is the ISO standard for aliasing columns. I don't think you can save much bytes by excluding the use of "AS"

    However a number of other ways for column aliasing exists in T-SQL and these are much of personal choice. Aaron Bertrand has an interesting article on this (the link is below):

    Bad Habits to Kick : Using AS instead of = for column aliases (Aaron Bertrand)


    Krishnakumar S

  • Monday, January 14, 2013 8:47 AM
     
     Answered

    And how I lament that AS is optional!

    I once spent a Friday afternoon looking at an INSERT statement that went:

      INSERT (col1, col2, col3, ..... col48)
        SELECT col1, col2 col3, .... col48
        FROM   ...

    And all SQL Server cared to tell me that there was a mismatch with the number of columns between the INSERT and the SELECT list.. Had AS been optional it would have told me "Incorrect syntax near 'col3'" and pointed me straight to the error.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se