Using the convert function for explicit conversions

The general conversion function, convert, converts between a variety of datatypes and, for date and time information, specifies a new display format. Its syntax is:

convert(datatype [(length) | (precision[, scale])] [null | not null],
	expression [, style ] ) 

This example uses convert in the select list:

select title, convert(char(5), total_sales) 
from titles 
where type = "trad_cook" 
title 
------------------------------------     ----- 
Onions, Leeks, and Garlic: Cooking 
    Secrets of the Mediterranean           375 
Fifty Years in Buckingham Palace 
    Kitchens                             15096 
Sushi, Anyone?                            4095 
 
(3 rows affected) 

Certain datatypes expect either a length or a precision and scale. If you do not specify a length, Adaptive Server uses the default length of 30 for character and binary data. If you do not specify a precision or scale, Adaptive Server uses the defaults of 18 and 0, respectively.