max value represented by bigint max value represented by bigint sql sql

max value represented by bigint


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)


See the answer provided in this similar question. There is no way, as far as I know, to programmatically find the answer you're looking for.

Based on the comments you posted on another answer, this would allow you to only have to change your values in one place, as opposed to multiple places.


You could also create a simple user defined function that returns the max bigint value:

CREATE FUNCTION maxbigint() RETURNS bigintAS BEGIN    RETURN CAST(0x7FFFFFFFFFFFFFFF AS bigint)ENDGO

Then you can use it wherever you want by invoking it: dbo.maxbigint().