Paul White continues a series on simple parameterization:
The details of how each data type is guessed are complex and incompletely documented. As a starting point, SQL Server infers a basic type from the textual representation of the value, then uses the smallest compatible subtype.
For a string of numbers without quotation marks or a decimal point, SQL Server chooses from
tinyint
,smallint
, andinteger
. For such numbers beyond the range of aninteger
, SQL Server usesnumeric
with the smallest possible precision. For example, the number 2,147,483,648 is typed asnumeric(10,0)
. Thebigint
type isn’t used for server-side parameterization. This paragraph explains the data types selected in the prior examples.
Read the whole thing to see what’s in and what’s out, as well as what this all means.