检查是否达到bigint限制 [英] Check if bigint limit is reached
问题描述
我正在使用ASP.net C#开发WebApp。
我试图以这种格式生成表格中的主键ID-45000-200(VARCHAR(900))
它以这种格式递增
ID-1-1
ID-1-2
ID-1-3
ID-2-1
我正在尝试开发一个用于生成此ID值的SQL UDF。
数字部分是BigInt所以我想知道是否有办法检查SQL SERVER 2012中是否达到了正BigInt Max值限制。
我尝试了什么:
我尝试过硬编码min&变量中的最大值&检查,但这似乎是愚蠢的。我想知道在SQL Server 2012中是否有更简洁的方法。
I am developing a WebApp using ASP.net C#.
I am trying to generate the primary key in the table in this format ID-45000-200 (VARCHAR(900))
It increments in this format
ID-1-1
ID-1-2
ID-1-3
ID-2-1
I am trying to develop a SQL UDF for generating this ID value.
The number part is BigInt so I want to know if there is any way to check if the positive BigInt Max value limit is reached in SQL SERVER 2012.
What I have tried:
I have tried hardcoding the min & max values in variables & checking against that, But that seems dumb. I want to know if there is a cleaner way of doing that in SQL Server 2012.
推荐答案
为什么检查,bigint
是2 ^ 63?
即使你每秒创建10000,你也不会在2900万年内达到极限!
Why check,bigint
is 2^63 ?
Even if you create 10000 every second you wouldn't reach the limit in 29 million years!
这篇关于检查是否达到bigint限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!