The maximum value submitted by bigint

Is there a way to get the maximum value that can be stored in bigint without hard coding?

Is there a function or constant that returns / contains this value?

+7
source share
3 answers

See the answer provided in this similar question . As far as I know, there is no way to programmatically find the answer you are looking for.

Based on the comments you sent to another answer, this will only allow you to change your values ​​in one place, as opposed to several places.

+7
source

bigint will always support

-2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) 

SQLQL TSQL does not define this as a constant, but it will always be -2 ^ 63 to 2 ^ 63 - 1

Ref .: int, bigint, smallint and tinyint (Transact-SQL)

+15
source

You can also create a simple custom function that returns the max bigint value:

 CREATE FUNCTION maxbigint() RETURNS bigint AS BEGIN RETURN CAST(0x7FFFFFFFFFFFFFFF AS bigint) END GO 

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

+3
source

All Articles