I am writing a rather long SQL script that is running close to 2000 lines of code. Since it becomes really difficult to comprehend a long script, I would like to break it up into logical units and separate them out in other SQL files.
What would be the best way of doing this? Would each logical unit need to be a Stored procedure? maybe a UDF?