Numeric literals in sql server 2008
Posted
by
costa
on Stack Overflow
See other posts from Stack Overflow
or by costa
Published on 2012-09-19T03:06:22Z
Indexed on
2012/09/19
3:38 UTC
Read the original article
Hit count: 102
sql-server-2008-r2
What is the type that sql server assigns to the numeric literal: 2. , i.e. 2 followed by a dot?
I was curious because:
select convert(varchar(50), 2.)
union all
select convert(varchar(50), 2.0)
returns:
2
2.0
which made me ask what's the difference between 2. and 2.0 type wise?
Sql server seems to assign types to numeric literals depending on the number itself by finding the minimal storage type that can hold the number. A value of 1222333 is stored as int while 1152921504606846975 is stored as big int.
thanks
© Stack Overflow or respective owner