Brian R. Bondy
Brian R. Bondy

Reputation: 347566

4 byte unsigned int in SQL Server?

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

Am I forced to use a bigint?

Upvotes: 19

Views: 28836

Answers (4)

Redha Student
Redha Student

Reputation: 11

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

Upvotes: -3

Gus Leo
Gus Leo

Reputation: 67

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

Upvotes: 0

Charles Bretana
Charles Bretana

Reputation: 146587

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

Upvotes: 15

Bill Karwin
Bill Karwin

Reputation: 562881

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

Upvotes: 9

Related Questions