views:

343

answers:

3

Hello, I'm working on an application that uses a third-party component, and this component returns a value that is of type UInt32.

I need to store this UInt32 in a Sql Server table. I was thinking about just use a simple int column and insert the value like this:

int value = (int)(cs - int.MaxValue);

But I'm not sure if this is the best way for such task.

Thanks

+1  A: 

I suggest you store it in a bigint column.

John Saunders
A: 

You should probably take + int.MinValue. As max is 2147483647 and min is -2147483648 for 32 bit signed integer. The zero steals one value from the positive side.

Stefan Lundström
+3  A: 
  1. Use a bigint or decimal(9,0) column and defined a check constraint to ensure it's between 0 and 4 billion.

  2. Defines a CLR datatype

gbn