The INT
data type is an integer value from -2,147,483,648 to 2,147,483,647.
INT
uses 4 bytes of storage.
INT
is the most commonly used integer data type in SQL Server.
A table with an INT
column.
CREATE TABLE DemoTable
(
Id INT IDENTITY,
CompanyName VARCHAR(100),
Employees INT
);
GO
INSERT INTO DemoTable VALUES ('Walmart', 2200000);
INSERT INTO DemoTable VALUES ('Amazon', 1298000);
INSERT INTO DemoTable VALUES ('Allied Universal', 800000);
INSERT INTO DemoTable VALUES ('FedEx Corporation', 650000);
INSERT INTO DemoTable VALUES ('Home Depot', NULL);
GO
SELECT * FROM DemoTable;
GO
DROP TABLE DemoTable;
GO
Id | CompanyName | Employees |
---|---|---|
1 | Walmart | 2200000 |
2 | Amazon | 1298000 |
3 | Allied Universal | 800000 |
4 | FedEx Corporation | 650000 |
5 | Home Depot | NULL |
ORDER |
---|
Id |
OrderDate |
OrderNumber |
CustomerId |
TotalAmount |
PRODUCT |
---|
Id |
ProductName |
SupplierId |
UnitPrice |
Package |
IsDiscontinued |
SELECT ProductName, I.UnitPrice, Quantity,
I.UnitPrice * Quantity AS 'Total'
FROM Product P
JOIN OrderItem I ON P.Id = I.ProductId
JOIN [Order] O ON I.OrderId = O.Id
WHERE OrderNumber = '542378'
ProductName | UnitPrice | Quantity | Total |
---|---|---|---|
Queso Cabrales | 14.00 | 12 | 168.00 |
Singaporean Hokkien Fried Mee | 9.80 | 10 | 98.00 |
Mozzarella di Giovanni | 34.80 | 5 | 174.00 |
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
MyBigInt | MyInt | MySmallInt | MyTinyInt |
---|---|---|---|
9223372036854775807 | 2147483647 | 32767 | 255 |