如何在 SQL Server 2008 中存储像 92233720368547758079223372036854775807922337203699
这样的大数字? bigint
允许的最大值是 9223372036854775807
我想我可以采取的一种方法是执行以下操作,将数字存储为 varchar(50)
,在 C# 代码中我可以做的是
BigInteger x = BigInteger.Parse("922337203685477580792233720368547758079223372036");
将不胜感激任何反馈。谢谢
最佳答案
在这种情况下要问自己的一个相关问题如下:
Is your really large number meant to be used as a number for arithmetic, or is it just some identifier?
然后你回复了
From what I understand is, the number is issued from an Oracle system from some governmental agency as a unique identifier, it can be as long as 0 - 50 number in length and we need to store that in our application
这应该会导致您得出与尝试将数据存储为数字不同的答案。
如果它只是一个标识符,那么您真的不需要将其存储或视为数字。从数据的角度来看,由数字组成的字符串(例如美国的社会安全号码或信用卡和贷款帐号)并不是真正的数字。它们是标识符字符串。以这种方式存储它们。
关于c# - 在 SQL Server 中存储非常大的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15707902/