SQL: T-SQL really needs Constants
In “Progamming 101”, developers learn that sprinkling hard-coded numbers and strings throughout their code, is a really lousy idea. Yet I regularly see T-SQL code that’s littered with hard-coded numbers and “special” string values. I really wish we could avoid that. It would greatly improve code quality, and improve debugging for procedures.
Take the following code as a really simple example:
SET @NextInterval = @CurrentInterval * 1440;
It’s not at all obvious why the value 1440 is there. In this case, it was the number of minutes in a day. Today, we can do this:
2020-03-05