String operators

String operators allow you to concatenate strings—except for LONGVARCHAR and LONGBINARY data types.

expression || expression   String concatenation (two vertical bars). If either string is NULL, it is treated as the empty string for concatenation.

expression + expression   Alternative string concatenation. When using the + concatenation operator, you must ensure the operands are explicitly set to character data types rather than relying on implicit data conversion.

For example, the following query returns the integer value 579:

SELECT 123 + 456;

However, the following query returns the character string 123456:

SELECT '123' + '456';

You can use the CAST or CONVERT functions to explicitly convert data types.