I inherited a SQL Server database where many tables have a primary key of type numeric(18,0)
.
What reasons (historical perhaps?) would someone choose this datatype for a primary key?
I would guess that the SQL Server database was originally designed in a version prior to SQL Server 2000, and this was the only way they could get an 'integer' bigger than the standard int. Since then, a bigint would have been more appropriate.
There is no right or wrong type for a key. You should choose attributes and types that accurately represent the business domain or match the input data. If the data you are recording is of numeric type then why wouldn't you store it as a numeric?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With