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

2

u/SantaCruzHostel Aug 26 '26

lol ain't that true. I have a 4000 line script that is needed once a month to import new patient records and do stuff needed to set up new pts in our system. When I first took it over I thought this could be better as a bunch of SPROCs called by a main script. But there is never any time to make things better if they aren't broken so guess who gets to look at the same 4000 line script each month