SQL Server Bigint Max Value
-
Posted on July 29, 2009 by Derek Dieter
-
8
The maximum value for an Bigint in SQL Server is:
-9223372036854775808 through 9223372036854775807
And the byte size is 8 bytes.
Here is the proof (Thanks to BJ)
[cc lang=”sql”]
DECLARE @max bigint, @min bigint
SELECT @max = 127, @min = 1
WHILE @min = 1 BEGIN
BEGIN TRY
SELECT @max = @max * 2 + 1
END TRY
BEGIN CATCH
BEGIN TRY
SET @min = -1 – @max
END TRY
BEGIN CATCH
SET @min = 0
END CATCH
END CATCH
END
SELECT @min , @max
[/cc]
other maximum values:
- Int: -2147483648 through 2147483647 (4 bytes)
- SmallInt: -32768 through 32767 (2 bytes)
- TinyInt: 0 through 255 (1 byte)
Post a comment
- Comments (RSS)
- Trackback
- Permalink
6 comments