How many lines of code do you have in your database?

Why should I care how many lines of code my database has? 

You are right, it shouldn’t matter.

But when you have a lot of code is also the beefiest that brings problems.

So what do you suggests? 

Pinal Dave already gave us a solution but I wanted to do the extra mile and give more details:

So now you have the list of object counts with the relative lines of code.

But also how many lines of code per object:

Lines of code in database

And that’s all folks.

Related

One Reply to “How many lines of code do you have in your database?”

  • a useful code, as a start. however this idea goes beyond just lines of code.
    i turned it into automated sql version control system.
    https://github.com/maximnl/msql/blob/main/MSQL_DATABASE_CODE.sql

    Description: Retrieves all user-defined database objects (stored
    procedures, functions, views, triggers) with their
    code definitions and line counts, and inserts them
    into a tracking table. Provides version control for
    database projects by automatically tracking code changes
    over time. Allows rollback to any previous version by
    retrieving historical definitions. Useful for code
    analysis, documentation, change tracking, and understanding
    database complexity.

    This code can be scheduled in daily data jobs (SQL Agent,
    SSIS, cron, etc.) to keep SQL versions automatically
    without manual intervention.

Leave a Reply

Your email address will not be published. Required fields are marked *