r/SQL • • 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

24 comments sorted by

View all comments

Show parent comment

1

u/wolskortt Aug 24 '26

Our Supply Department works for 6 or 7 companies since we have a holding, so I'm querying from an ERP for the whole Supply operations.

Even with everything in CTE's, my query is 1276 lines at the moment and I'm not finished. (It's for a multisubject dashboard)