HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

Datatype bigger than bigint

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
bigintthandatatypebigger

Problem

I want to use dataype which can hold more than 19 digits. So is there any datatype available which can hold larger than 19 digits?

Solution

Numeric/Decimal, Float/Real. There's a great answer here, some official documentation here and here, and I also posted a few opinions ages ago, but here is a quick demonstration:

-- overflow error:

DECLARE @x BIGINT        = 9999999999999999999;

GO

-- works:

DECLARE @x DECIMAL(38,0) = 99999999999999999999999999999999999999;

Code Snippets

-- overflow error:

DECLARE @x BIGINT        = 9999999999999999999;

GO

-- works:

DECLARE @x DECIMAL(38,0) = 99999999999999999999999999999999999999;

Context

StackExchange Database Administrators Q#51536, answer score: 25

Revisions (0)

No revisions yet.