Export (0) Print
Expand All

2.2.5.1 General Rules

Data structure encodings in TDS are defined in terms of the following fundamental definitions:

BIT: A single bit value of either 0 or 1.

BIT = %b0 / %b1

BYTE: An unsigned single byte (8-bit) value. The range is 0 to 255.

BYTE = 8BIT

BYTELEN: An unsigned single byte (8-bit) value representing the length of the associated data. The range is 0 to 255.

BYTELEN = BYTE

USHORT: An unsigned 2-byte (16-bit) value. The range is 0 to 65535.

USHORT = 2BYTE

LONG: A signed 4-byte (32-bit) value. The range is -(2^31) to (2^31)-1.

LONG = 4BYTE

ULONG: An unsigned 4-byte (32-bit) value. The range is 0 to (2^32)-1

ULONG = 4BYTE

DWORD: An unsigned 4-byte (32-bit) value. The range when used as a numeric value is 0 to (2^32)-1.

DWORD = 32BIT

LONGLONG: A signed 8-byte (64-bit) value. The range is –(2^63) to (2^63)-1.

LONGLONG = 8BYTE

ULONGLONG: An unsigned 8-byte (64-bit) value. The range is 0 to (2^64)-1.

ULONGLONG = 8BYTE

UCHAR: An unsigned single byte (8-bit) value representing a character. The range is 0 to 255.

UCHAR = BYTE

USHORTLEN: An unsigned 2-byte (16-bit) value representing the length of the associated data. The range is 0 to 65535.

USHORTLEN = 2BYTE

USHORTCHARBINLEN: An unsigned 2-byte (16-bit) value representing the length of the associated character or binary data. The range is 0 to 8000.

USHORTCHARBINLEN = 2BYTE

LONGLEN: A signed 4-byte (32-bit) value representing the length of the associated data. The range is -(2^31) to (2^31)-1.

LONGLEN = 4BYTE

ULONGLONGLEN: An unsigned 8-byte (64-bit) value representing the length of the associated data. The range is 0 to (2^64)-1.

ULONGLONGLEN = 8BYTE

PRECISION: An unsigned single byte (8-bit) value representing the precision of a numeric number.

PRECISION = 8BIT

SCALE: An unsigned single byte (8-bit) value representing the scale of a numeric number.

SCALE = 8BIT

GEN_NULL: A single byte (8-bit) value representing a NULL value.

GEN_NULL = %x00

CHARBIN_NULL: A 2-byte (16-bit) or 4-byte (32-bit) value representing a T-SQL NULL value for a character or binary data type. Please refer to TYPE_VARBYTE (see section 2.2.5.2.3) for additional details.

CHARBIN_NULL = (%xFF %xFF) / (%xFF %xFF %xFF %xFF)

FRESERVEDBIT: A FRESERVEDBIT is a BIT value used for padding that does not transmit information. FRESERVEDBIT fields SHOULD be set to %b0 and MUST be ignored on receipt.

FRESERVEDBIT = %b0

FRESERVEDBYTE: A FRESERVEDBYTE is a BYTE value used for padding that does not transmit information. FRESERVEDBYTE fields SHOULD be set to %x00 and MUST be ignored on receipt.

FRESERVEDBYTE = %x00

UNICODECHAR: A single Unicode character in UCS-2 encoding, as specified in UNICODE [UNICODE].

UNICODECHAR = 2BYTE

Notes

  • All integer types are represented in reverse byte order (little-endian) unless otherwise specified.

  • FRESERVEDBIT and FRESERVEDBYTE are often used to pad unused parts of a byte or bytes. The value of these reserved bits SHOULD be ignored. These elements are generally set to 0.

 
Show:
© 2014 Microsoft