liveBook · Manning

TINYINT

As explained in 100 SQL Server Mistakes and How to Avoid Them

TINYINT is a SQL Server integer data type that stores nonnegative whole-number values using one byte.

Mistake #6: choosing TINYINT merely because a column stores whole numbers. TINYINT uses one byte and stores values from 0 through 255, but that range can be too small for identifiers expected to reach 300. section 3.1

The Employees scenario

EmployeeID and ManagerID require up to 300 unique values, so TINYINT is too restrictive. SMALLINT accommodates the expected values while saving two bytes per row compared with INT. For a 0-or-1 flag such as StaffOrContract, BIT is the more suitable choice. section 3.1

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Defines TINYINT through its range and one-byte size, then contrasts it with practical identifier and flag choices.
Examples
Uses employee identifiers, a StaffOrContract flag, an Employees table, and DATALENGTH storage checks.
What you can do after
Evaluate integer-column choices and verify their storage sizes with DATALENGTH.
How it connects
Connects TINYINT with SMALLINT, INT, BIGINT, BIT, integer columns, and entity-relationship diagrams.

Also explained in

Compare how 3 books explain TINYINT →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.