A constant, also known as a literal or a scalar value, is a symbol that represents a specific data value. The format of a constant depends on the data type of the value it represents.
If the QUOTED_IDENTIFIER option has been set OFF for a connection, character strings can also be enclosed in double quotation marks, but the Microsoft® OLE DB Provider for SQL Server and ODBC driver automatically use SET QUOTED_IDENTIFIER ON. The use of single quotation marks is recommended.
If a character string enclosed in single quotation marks contains an embedded quotation mark, represent the embedded single quotation mark with two single quotation marks. This is not necessary in strings embedded in double quotation marks.
Examples of character strings are:
'Cincinnati'
'O''Brien'
'Process X is 50% complete.'
'The level for job_id: %d should be between %d and %d.'
"O'Brien"
Empty strings are represented as '' (two single quotation marks with nothing in between). In 6.x compatibility mode, an empty string is treated as a single space.
0xAE
0x12Ef
0x69048AEFDD010E
0x (empty binary string)
'April 15, 1998'
'15 April, 1998'
'980415'
'04/15/98'
Examples of time constants are:
'14:30:24'
'04:24 PM'
1894
2
1894.1204
2.0
101.5E5
0.5E-2
$12
$542023.14
'6F9619FF-8B86-D011-B42D-00C04FC964FF'
0xff19966f868b11d0b42d00c04fc964ff
To indicate whether a number is positive or negative, apply the + or - unary operators to a numeric constant. This creates a numeric expression that represents the signed numeric value. Numeric constants default to positive if the + or - unary operators are not applied.
+145345234
-2147483648
+145345234.2234
-2147483648.10
+123E-3
-12E5
-$45.56
+$423456.99
Expressions | Operators |
Data Types | Using Constants |