First question: can there be leading zeroes in those document numbers? If so,
decimal(23, 0)is out of the game and the only question is whether you should have
char(23)would be the obvious choice if they were to stick with these 23-digit numbers, but with the change to 15 digits, it seems that
varcharis the better choice.
Even if there can be no leading zeroes, my gut feeling says character, because to me this feels like a string. But, yes, you will save some space with decimal.
If you go for varchar, you can consider to use a binary collation to speed operations on this column.
Hi @Erland Sommarskog ,
That was interesting. I found 148 old, historical, records in 2004 with a leading 0. Although, I think you are right, and I even think I should shield this right now before this number logic turns into something different, like backslashes, pipes, or some other char logic, in the future.
As for the binary collation I'm forced with a linguistic collation for now: Latin1_General_CI_AS, due to customer organisation policies.