Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to store UInt32 in Sql Server

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.

like image 294
Paulo Avatar asked Jan 24 '23 18:01

Paulo


2 Answers

  1. Use a bigint or decimal(10,0) column and defined a check constraint to ensure it's between 0 and 4 billion.

  2. Defines a CLR datatype

like image 59
gbn Avatar answered Jan 26 '23 07:01

gbn


I suggest you store it in a bigint column.

like image 24
John Saunders Avatar answered Jan 26 '23 07:01

John Saunders