Data type ?

Posted on 2012-08-13
Last Modified: 2012-08-13
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?
Question by:wasabi3689
    LVL 65

    Accepted Solution

    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.
    LVL 65

    Expert Comment

    by:Jim Horn
    Also, SQL Server does not automatically promote other integer data types (tinyint, smallint, and int) to bigint.  (sentence before yellow Caution box)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now