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?
7
Upvotes
View all comments
1
u/dataindenver Aug 26 '26
A couple of companies ago I was handed a T SQL stored procedure that was 2k lines just to calculate Market Cap for a company. Was asked to optimize it and I removed maybe 50-100 lines…