Skip to content
 

SQL Server Max Int Value

The maximum value for an integer in SQL Server is:

-2147483648 through 2147483647

And the byte size is 4 bytes

other maximum values:

  • BigInt: -9223372036854775808 through 9223372036854775807 (8 bytes)
  • SmallInt: -32768 through 32767 (2 bytes)
  • TinyInt: 0 through 255 (1 byte)

Here is the proof:

DECLARE @int int = 0

WHILE 1 = 1
BEGIN
    BEGIN TRY
        SET @int = @int + 1000
    END TRY
    BEGIN CATCH
		BEGIN TRY
			SET @int = @int + 1
		END TRY
		BEGIN CATCH
			SELECT @int
			BREAK;
		END CATCH
    END CATCH
END


Popular search terms:

4 Comments

  1. Raj says:

    For a 4 byte int, if you insert a million records everyday, you can keep doing it more than 5 years ;)

  2. Glen says:

    Extrapolating your exactness on this in negative values – lol

    DECLARE @int int
    SET @int = 0
    WHILE 1 = 1
    BEGIN
    BEGIN TRY
    SET @int = @int – 1000
    END TRY
    BEGIN CATCH
    BEGIN TRY
    SET @int = @int – 1
    END TRY
    BEGIN CATCH
    SELECT @int
    BREAK;
    END CATCH
    END CATCH
    END

    result: -2147483648

    “never argue with fools, they beat you with experience every time”

  3. Glen says:

    Sorry your example needs a slight mod to work with SQL 2005;

    DECLARE @int int
    SET @int = 0
    WHILE 1 = 1
    BEGIN
    BEGIN TRY
    SET @int = @int + 1000
    END TRY
    BEGIN CATCH
    BEGIN TRY
    SET @int = @int + 1
    END TRY
    BEGIN CATCH
    SELECT @int
    BREAK;
    END CATCH
    END CATCH
    END

    result: 2147483647

post a comment OR Post Your Question on our ASK! Community!