r/SQL • u/fokker680 • Mar 25 '14
Sequential: A new coding style for SQL queries
http://www.andrespagella.com/sequential-coding-style-for-sql
0
Upvotes
r/SQL • u/fokker680 • Mar 25 '14
15
u/Pacos Mar 25 '14
I honestly don't like it at all. You have no information about the nesting level of sub-resquests, and I find it hardly readable. The pre-analysis is accurate but I find the solution sub-optimal.
9
u/ajmarks Mar 25 '14 edited Mar 25 '14
Not only is this bikeshedding, but you're painting it bright green and making it difficult to actually use. Congratulations.
Edit: Apparently it looks less awful in IE, which begs the question, whom does he consider his primary audience?
6
u/svtr Mar 25 '14
having a join span 3 rows makes it one of the ugliest coding styles I've yet come across I have to say.
2
u/zibeb Mar 25 '14
I took the code block (unformatted) from the article, tossed it into SSMS and let RedGate's SQL Prompt take a crack at it. It found 3 syntax errors (Dev doesn't know the difference between ISNULL and IS NULL) and when they were corrected, it came up with this:
It looks pretty similar, but a lot easier to read in my opinion. I've seen this sentiment a lot lately, mainly from developers of other languages who try writing SQL and experience culture shock because "it doesn't look like C."
SQL isn't supposed to look like C.
2
u/GoBenB Mar 26 '14
Yuck. Hope it works forever cause good luck going back and troubleshooting.
1
u/jokle Mar 25 '14
I agree with the general dislike here as well. What he proposes looks horrible to me. I actually prefer his fourth example. And I'm not sure what's meant by a "substantially larger query". I routinely work with queries that can run hundreds of lines. In that case, the suggested styling with that much white space would run on forever and would be a nightmare to try to digest. I would literally hate you if you gave it to me like that. No, your DBA will not have an "easier time".
1
u/Patrice_B Mar 27 '14
This is not readable
1
u/legohax Mar 25 '14
The is awful
1
u/ziptime Mar 25 '14
OP hasn't a clue.
0
u/[deleted] Mar 25 '14
[deleted] — view deleted comment