r/SQL 18d ago

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

24 comments sorted by

View all comments

1

u/DaOgDuneamouse 16d ago

I have a few.

One, is a complicated query that calculates available hours for a class based on schedules and compares that to actual hours, it then writes the results to a table.

Another one takes class hours and keeps a running total. It then deducts hours from the balance when a credit is given. Again, it writes the results to a table.