a memorable feature of some of the India-originating code I have seen were stored procedures that were handling let’s say 2 or 3 related cases using 2 or 3 blocks of copy-paste SQL code. Sometimes pretty big blocks, so I used diff to actually figure out which couple of words or lines differed.
How easy or hard it would have been to write it more compactly for the same cases I am not sure - maybe sometimes the CASE statement would work, and in others it would have taken dynamic SQL. Using a different set of cases apparently did not occur to the programmer.
Question 1 - is this a common problem in low quality stored procedures, or is this an uncommon signature style of whoever wrote that?
Question 2. If, hypothetically, this is a common thing and reflective of some incompatibility between SQL syntax and coding skills of lesser programmers (well, judging by some of responses I have seen in other threads, some cases of the syntax are not a walk in the park for the best of us) would it make more sense to generate all stored procedures dynamically from “stored procedure markup language” (let’s say a dialect of JSP, I don’t like the poor PHP syntax verification) using a separate “stored procedure management studio”? That way no more worries about finer points of syntax preventing a single query from handling multiple cases - you just write the code that generates separate query for each case based on a template and then the system reports if any of these queries are malformed. Then you fix that and you store the scripts into the version control instead of the stored procedures themselves.
Incidentally, I realize that the “studio” is not really needed and this could be done on the architectural level in the codebase itself. But I think that specialized tools are always a good idea for complex problems. Besides, the type of shops that would benefit most from this are also likely to be those deficient in architecture department.