3. Understanding SQL Data Types : Literals : String Literals
 
Share this page                  
String Literals
String literals are specified by one or more characters enclosed in single quotes. The default data type for string literals is varchar, but a string literal can be assigned to any character data type or to money or date data type without using a data type conversion function.
To compare a string literal with a non-character data type (A), you must either cast the string literal to the non-character data type A, or cast the non-character data type to the string literal type. Failure to do so causes unexpected results if the non-character data type contains the ‘NULL (0) value.
For example, to compare the function X string literal that returns a varchar data type to a byte data type, cast the result of the X function as follows:
SELECT * FROM uid_table
       WHERE uid = BYTE(X’010000000000000000000000000000’)
or
SELECT * FROM uid_table
       WHERE HEX(uid) = ’010000000000000000000000000000’