4 Replies Latest reply on Aug 24, 2006 8:40 AM by Newsgroup_User

# smallint, bigint, int, tinyint, number?

In MS-SQL, I am looking at a field that is designated "smallint" In the
"Design" view, the "length" has "2." I don't understand what this "2" means.

In my definition of smallint, it states that it's an "integer data
from -2^15 through 2^15-1.

Can someone explain what "-2^15 through 2^15-1" means and why the length is
"2?"

Thanks.

• ###### 1. Re: smallint, bigint, int, tinyint, number?
> Can someone explain what "-2^15 through 2^15-1" means

http://www.databasejournal.com/features/mssql/article.phpr/2212141

"If you need to store integer data from -32,768 through 32,767, use smallint
data type. The columns with smallint data type use only two bytes to store
their values, in comparison with four bytes and eight bytes used to store
the columns with int and bigint data types accordingly. For example, if you
design tables for a company with several hundred employees, you can create
an employee table with the EmployeeID smallint column to store the unique
number of each employee."

IMHO, the reasons to use the 'other' int fields isn't usually worth it
unless you have very specific data, and you have a strong need to save bits
here and there. In otherwords, for most small to mid-size projects, I don't
think there's anything wrong with keeping your values as INTs and letting it
be.

-Darrel

• ###### 2. Re: smallint, bigint, int, tinyint, number?
Thanks

------------------------------------------------------------------
> http://www.databasejournal.com/features/mssql/article.phpr/2212141
>
> "If you need to store integer data from -32,768 through 32,767, use
> smallint data type. The columns with smallint data type use only two bytes
> to store their values, in comparison with four bytes and eight bytes used
> to store the columns with int and bigint data types accordingly. For
> example, if you design tables for a company with several hundred
> employees, you can create an employee table with the EmployeeID smallint
> column to store the unique number of each employee."
>
> IMHO, the reasons to use the 'other' int fields isn't usually worth it
> unless you have very specific data, and you have a strong need to save
> bits here and there. In otherwords, for most small to mid-size projects, I
> don't think there's anything wrong with keeping your values as INTs and
> letting it be.
>
> -Darrel
>

• ###### 3. Re: smallint, bigint, int, tinyint, number?
On a similar note, I'm trying to set a default value of 10000 but when I add
the new table and specify 10000 in the default value line, it ends up
"<NULL>" in the table. I tried putting the 10000 in (10000) but that didn't
work either.

Any ideas?

• ###### 4. Re: smallint, bigint, int, tinyint, number?
nevermine, figured it out. I had the "allow nulls" checked

"lee" <lfairban_nospam@amep.com> wrote in message
news:eckgt4\$f2r\$1@forums.macromedia.com...
> On a similar note, I'm trying to set a default value of 10000 but when I
> add the new table and specify 10000 in the default value line, it ends up
> "<NULL>" in the table. I tried putting the 10000 in (10000) but that
> didn't work either.
>
> Any ideas?
>