Dofactory.com
Dofactory.com
Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

SQL BIGINT Data Type

The BIGINT data type is an integer value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

BIGINT is SQL Server's largest integer data type. It uses 8 bytes of storage.

BIGINT should be used when values can exceed the range of INT.

Example

#

A table with a BIGINT column.

CREATE TABLE DemoTable  
( 
  Id INT IDENTITY, 
  Company VARCHAR(100),
  NetWorth BIGINT
);
GO  

INSERT INTO DemoTable VALUES ('Apple', 2252300000000);  
INSERT INTO DemoTable VALUES ('Microsoft', 1966600000000);  
INSERT INTO DemoTable VALUES ('Saudi Arabian Oil Company', 1897200000000);
INSERT INTO DemoTable VALUES ('Amazon', 1711800000000); 
INSERT INTO DemoTable VALUES ('Alphabet', NULL); 
GO  

SELECT * FROM DemoTable;
GO

DROP TABLE DemoTable;
GO
Result:  5 records
Id Company NetWorth
1 Apple 2252300000000
2 Microsoft 1966600000000
3 Saudi Arabian Oil Company 1897200000000
4 Amazon 1711800000000
5 Alphabet NULL

More Examples

BIGINT with OTHER INT DATA TYPES

Problem: List the maximum value of each integer data type.
CREATE TABLE DemoTable  
( 
  MyBigInt BIGINT,
  MyInt INT,
  MySmallInt SMALLINT,
  MyTinyInt TINYINT
);
GO  

INSERT INTO DemoTable VALUES (9223372036854775807, 2147483647, 32767, 255);  
GO  

SELECT * FROM DemoTable;
GO

DROP TABLE DemoTable;
GO
Result:  1 record
MyBigInt MyInt MySmallInt MyTinyInt
9223372036854775807 2147483647 32767 255

You may also like



Last updated on Dec 21, 2023

Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.