4 byte unsigned int in SQL Server?

谁都会走 提交于 2019-12-18 04:31:42

问题


Is there a 4 byte unsigned int data type in MS SQL Server?

Am I forced to use a bigint?


回答1:


It doesn't seem so.

Here's an article describing how to create your own rules restricting an int to positive values. But that doesn't grant you positive values above 2^31-1.

http://www.julian-kuiters.id.au/article.php/sqlserver2005-unsigned-integer




回答2:


Can you just add/subtract 2,147,483,648 (2^31) to the regular int ? (subtract on the way in, & add coming out) I know it sounds silly, but if you declare a custom datatype that does this, it's integer arithmetic and very fast.... It just won't be readable directly from the table




回答3:


You can use bigint with checked the constraint, but datatype will still in 8 byte :(




回答4:


I used BINT(11) instead of INT(11), and it acts as UNSIGNED INT(11)



来源:https://stackoverflow.com/questions/306291/4-byte-unsigned-int-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!