11

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?

4
  • 3
    Out of curiosity, what kind of problem needs to deal with values in quintillion range? Scientific computing comes into mind.
    – vonPryz
    Oct 15, 2013 at 13:16
  • @vonPryz The calculation of modular multiplicative inverses for the generation of asymmetric keys is one thing that comes to my mind. It can be used to create a reversible 'randomization' of bigint numbers, for example. Oct 4, 2019 at 13:40
  • @vonPryz Late to the game, but barcode numbers, voucher IDs and other long numbers? Or is it better practice to store that as nvarchars?
    – SvendK
    Nov 19, 2020 at 10:14
  • 1
    @SvendK That really depends. Storing not-really-numbers such as GTIN codes as numbers can cause a lot of headaches. When the leading zeroes are mandatory, using a numeric type is not the smart solution.
    – vonPryz
    Nov 19, 2020 at 10:41

1 Answer 1

25

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.