• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Data type ?

I have MS SQL database. I have a table, i want to define a field as bigint.

I want to know if the database will still reserve more space for the field if indeed the data in the bigint field is only int, not auto know this is int only, not reserve extra space?
0
wasabi3689
Asked:
wasabi3689
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
A bigint will take up 8 bytes of memory for each row, regardless of how many bytes are used.

afaik SQL will not save it as less bytes if it fits a lesser datatype such as smallint or int, and then switch to bigint if the values dictate.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Also, SQL Server does not automatically promote other integer data types (tinyint, smallint, and int) to bigint.  (sentence before yellow Caution box)

http://msdn.microsoft.com/en-us/library/ms187745.aspx
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now