Active Server - Shorten Your SQL Query By Assigning Aliases To Long Table And Field Names

In the early days of database development, we kept table names and field names down to 6-8 generic characters like XPNOWHS5, NPPDK12B in table WWSYSPDF. Ten years later when no one knew what these letters represented, the designers moved the naming conventions to the other end of the spectrum in frustration. Now, the field names are External_Printer_Number_Warehouse_Five in table Worldwide_System_Printer_Definitions. Who wants to build a query using these names? If you don't, consider using alias names in place of the long actual names. Following is a quick example of a query using alias names:

  • Select External_Printer_Number_Warehouse_Five as ep5 from Worldwide_System_Printer_Definitions as wwp Where ep5 <> 'blah'

You will, of course, have to use the actual name once in the query. However, after you've used the As keyword to introduce the alias name, you can use that name for all other times that you reference the table or field. If desired, you can omit the As keyword when defining aliases.

Go back