Aggregate functions as row aggregates  Converting character data to a noncharacter type

Chapter 2: Transact-SQL Functions

Datatype conversion functions

Datatype conversion functions change expressions from one datatype to another and specify new display formats for date and time information. The datatype conversion functions are:

You can use the datatype conversion functions in the select list, in the where clause, and anywhere else an expression is allowed.

Adaptive Server performs certain datatype conversions automatically. These are called implicit conversions. For example, if you compare a char expression and a datetime expression, or a smallint expression and an int expression, or char expressions of different lengths, Adaptive Server automatically converts one datatype to another.

You must request other datatype conversions explicitly, using one of the built-in datatype conversion functions. For example, before concatenating numeric expressions, you must convert them to character expressions.

Adaptive Server does not allow you to convert certain datatypes to certain other datatypes, either implicitly or explicitly. For example, you cannot convert the following:

Unsupported conversions result in error messages.

Figure 2-1 indicates whether individual datatype conversions are performed implicitly, explicitly, or are not supported.

Figure 2-1: Explicit, implicit, and unsupported datatype conversions.

Explicit, implicit, and unsupported datatype conversions.

Datatype conversion key





Copyright © 2005. Sybase Inc. All rights reserved. Converting character data to a noncharacter type

View this book as PDF