There are additional considerations for using convert.
convert, a datatype conversion function, converts between a wide variety of datatypes and reformats date/time and money data for display purposes.
If they are compressed, convert decompresses large object (LOB) columns before converting them to other datatypes.
select convert(varchar(3), ut) from untable --- AB
convert generates a domain error when the argument falls outside the range over which the function is defined. This should happen rarely.
Use null or not null to specify the nullability of a target column. Specifically, this can be used with select into to create a new table and change the datatype and nullability of existing columns in the source table (See Example 8, above).
The result is an undefined value if:
The expression being converted is to a not null result.
The expression’s value is null.
Use the following select statement to generate a known non-NULL value for predictable results:
select convert(int not null isnull(col2, 5)) from table1
You can use convert to convert an image column to binary or varbinary. You are limited to the maximum length of the binary datatypes, which is determined by the maximum column size for your server’s logical page size. If you do not specify the length, the converted value has a default length of 30 characters.
You can use unichar expressions as a destination datatype or you can convert them to another datatype. unichar expressions can be converted either explicitly between any other datatype supported by the server, or implicitly.
If you do not specify the length when unichar is used as a destination type, the default length of 30 Unicode values is used. If the length of the destination type is not large enough to accommodate the given expression, an error message appears.
See also Transact-SQL Users Guide; Java in Adaptive Server Enterprise for a list of allowed datatype mappings and more information about datatype conversions involving Java classes.