• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

TSQL - largest integer type bigint?

This is mostly a TSQL question but C# enters in as well (down at the bottom).

What is the biggest TSQL data type for positive integer values?  Is it bigint?

If I am getting an overflow, what can be done?

I read somewhere that any calculations are done with both numbers as integers and the result is only casted as a bigint, or something or other.  I understand that to mean:

integer * integer = bigint

because you can't do this:

bigint * bigint = bigint             --(overflow??)

I think it is this line in the TSQL that is causing the problem:

(excerpted from the stored proc):


      @LookupListKey bigint,



SET @LookupListKey = (SELECT MAX(LookupListKey) * MAX(LookupListKey) FROM UNAdmin.SystemLocations)

I've been thinking of storing the result as a string, thinking that a string representation could represent an integer value far larger than int or bigint.  

Suggestions for storing very large numbers that won't fit in a bigint?

Side question:  What C# data type can hold the largest positive integer value?  What is the C# data type compatible with bigint?
Tom Knowlton
Tom Knowlton
  • 2
2 Solutions
AndyAinscowFreelance programmer / ConsultantCommented:
DECIMAL I think stores more than a bigint.
Tom KnowltonWeb developerAuthor Commented:
Huh....okay.  : )
Kyle AbrahamsSenior .Net DeveloperCommented:
BigInt:  -9.2 x 10^18 to 9.2 x 10^18
Decimal(38,0):  -10^38 to 10^38
Tom KnowltonWeb developerAuthor Commented:
Thank you both.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now