Converting numbers to a character type

Exact and approximate numeric data can be converted to a character type. If the new type is too short to accommodate the entire string, an insufficient space error is generated. For example, the following conversion tries to store a 5-character string in a 1-character type:

select convert(char(1), 12.34)
Insufficient result space for explicit conversion
of NUMERIC value '12.34' to a CHAR field.

When converting float data to a character type, the new type should be at least 25 characters long.

NoteThe str function may be preferable to convert or cast when making conversions, because it provides more control over conversions and avoids errors.