r/SQL • u/Prestigious_Flow_465 • Aug 22 '26
SQL Server Query Length Flex
Those of you who write very long queries (100s to thousands lines of code). Does it do only one thing or it's just your query notebook where every small part does something non related?
I am curious in which cases its necessary thousands lines of codes. Explain me what does your longest query is for?
6
Upvotes
View all comments
Show parent comment
5
u/nachos_nachas Aug 23 '26
ERP supply chain inventory values was my PR for query size. But I saw one that was even larger for payroll calculations that had a ton of customer-demanded logic to account for employees who made different wages depending on their job worked AND overtime rules for when the same employees worked at different shops in different states. That was a nightmare, but he made it pretty easy to read the code.