Every year my company runs a graduate bootcamp, 2 months of teaching new grads what they need to know to write production-ready software. This post was inspired by something that happened during this year’s bootcamp.
One afternoon I noticed a post in the chat channel recommending using DECIMAL over NUMERIC because “the scale in the declaration for the numeric is the exact scale, but for decimal it’s the minimum scale.” Essentially saying that NUMERIC(5,2) cannot store 1000, but DECIMAL(5,2) can. There was a link to a blog that explained that in more details. Sounds good, but there’s one problem…
And a quick check of the Microsoft documentation states that DECIMAL is a synonym of NUMERIC (and the error messages imply the same)
Now, I’m not going to link to that blog, because a careful reading of the blog shows it to be correct in that statement, but the blog is talking about ANSI-standard SQL, not the T-SQL variant that SQL Server uses.
This is a very easy mistake to make, to misread what version of a product a blog post refers to, to misread what product a blog post refers to. And that’s ignoring the very real possibility that the blog post might be incorrect.
Trust what you read on people’s blogs but verify it (yes, including mine). Test out the assertions if you can, run example code, check against other blogs, check against the documentation. Just don’t assume that everything you read is correct and applies to the situation you are it. It won’t be.