A 4-byte Unsigned Int for Sql Server 2008?

Posted by Jeff Meatball Yang on Stack Overflow See other posts from Stack Overflow or by Jeff Meatball Yang
Published on 2010-04-25T23:20:11Z Indexed on 2010/04/25 23:23 UTC
Read the original article Hit count: 234

Filed under:
|
|

I understand there are multiple questions about this on SO, but I have yet to find a definitive answer of "yes, here's how..."

So here it is again: What are the possible ways to store an unsigned integer value (32-bit value or 32-bit bitmap) into a 4-byte field in SQL Server?

Here are ideas I have seen:

1) Use a -1*2^31 offset for all values

  • Disadvantages: need to perform math on the values before reading/writing/aggregating.

2) Use 4 tinyint fields

  • Disadvantages: need to concatenate values to perform any operations

3) Use binary(4)

  • Disadvantages: actually uses 4 + 2 bytes of space

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about unsigned