Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

choosing primary key datatype numeric (18,0)

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?

like image 835
JoelFan Avatar asked Jun 03 '11 16:06

JoelFan


2 Answers

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.

like image 121
MartW Avatar answered Nov 13 '22 23:11

MartW


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?

like image 26
nvogel Avatar answered Nov 14 '22 01:11

nvogel