Is there a way to get the max value that can be stored in a bigint, without hardcoding it?
Is there a function or a constant that returns/contains this value?
The BigInt data type in SQL Server is the 64-bit representation of an integer. It takes up 8 bytes of storage. It can range from -2^63 (-9,223,372,036,854,775,808) to 2^63 (9,223,372,036,854,775,807).
A BIGINT is always 8 bytes and can store -9223372036854775808 to 9223372036854775807 (signed) or 0 to 18446744073709551615 (unsigned).
Description: BIGINT is the SQL99-compliant 64-bit signed integer type. It is available in Dialect 3 only. BIGINT numbers range from -263 .. 263-1, or -9,223,372,036,854,775,808 ..
Maximum value is 2147483647.
BigInteger Larger Than Long. The signed long has a minimum value of -263 (1000 0000 … 0000) and a maximum value of 263-1 (0111 1111 … 1111). To create a number over those limits, we need to use the BigInteger class.
A bigint is always going to support
-2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
SQL Server TSQL does not define this as a constant, but it is always going to be -2^63 to 2^63 - 1
Ref.: int, bigint, smallint, and tinyint (Transact-SQL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With