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

Datatype of Mixed-Mode Expressions [Table of Contents] Standards and Compliance

Reference Manual

[-] Chapter 1: System and User-Defined Datatypes
[-] Converting One Datatype to Another

Converting One Datatype to Another

Many conversions from one datatype to another are handled automatically by Adaptive Server. These are called implicit conversions. Other conversions must be performed explicitly with the convert, inttohex, and hextoint functions. See "Datatype Conversion Functions" in Chapter 2, "Transact-SQL Functions," for details about datatype conversions supported by Adaptive Server.

Automatic Conversion of Fixed-Length NULL Columns

Only columns with variable-length datatypes can store null values. When you create a NULL column with a fixed-length datatype, Adaptive Server automatically converts it to the corresponding variable-length datatype. Adaptive Server does not inform the user of the datatype change.

Table 1-4 lists the fixed- and variable-length datatypes to which they are converted. Certain variable-length datatypes, such as moneyn, are reserved datatypes; you cannot use them to create columns, variables, or parameters:

Table 1-4: Automatic conversion of fixed-length datatypes

Original Fixed-Length Datatype

Converted To

char

varchar

nchar

nvarchar

binary

varbinary

datetime

datetimn

float

floatn

int, smallint, and tinyint

intn

decimal

decimaln

numeric

numericn

money and smallmoney

moneyn

Handling Overflow and Truncation Errors

The arithabort option determines how Adaptive Server behaves when an arithmetic error occurs. The two arithabort options, arithabort arith_overflow and arithabort numeric_truncation, handle different types of arithmetic errors. You can set each option independently, or set both options with a single set arithabort on or set arithabort off statement.

The arithignore option determines whether Adaptive Server prints a warning message after an overflow error. By default, the arithignore option is turned off. This causes Adaptive Server to display a warning message after any query that results in numeric overflow. To ignore overflow errors, use set arithignore on.

Note: , The arithabort and arithignore options were redefined for release 10.0. If you use these options in your applications, examine them to be sure they still produce the desired effects.

Datatype of Mixed-Mode Expressions [Table of Contents] Standards and Compliance