Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Rearranging
the order of columns [Table of Contents] Expressions

Transact-SQL User's Guide

[-] Chapter 2 Queries: Selecting Data from a Table
[-] Choosing columns: the select clause
[-] Renaming columns in query results

Renaming columns in query results

When query results display, the default heading for each column is the name given to it when it was created. You can rename a column heading for display purposes by using one of the following instead of only the column name in a select list.

column_heading = column_name

or:

column_name column_heading

or:

column_name as column_heading

This provides a substitute name for the column. For example, to change pub_name to "Publisher" in the previous query, type any of the following statements:

select Publisher = pub_name, pub_id 
from publishers 
select pub_name Publisher, pub_id 
from publishers 
select pub_name as Publisher, pub_id 
from publishers 

The results of these statements look like this:

Publisher                 pub_id 
----------------------    ------ 
New Age Books             0736 
Binnet & Hardley          0877 
Algodata Infosystems      1389 
 
(3 rows affected)


Rearranging
the order of columns [Table of Contents] Expressions