April 18, 2012 6:08 am
Hi Friends,
In development fields we never know which different type of problem statement we may need to face , We just need to stay calm and focused and what client want and completing all of their requirement.
In one of my previous post we have already started analysing How to find Number of lines of Code in procedure or function , Now in this post we are covering for Calculating number of lines per Database is .
If you have miss the previous post then you can have continuity from that post where link is follows
:BISQL # 90 – How to find Number of lines of Code in procedure or function
We will use Adventure Works DB for this script
I have just tweaked query posted in above article and got desired result
--Total No of line of Code SELECT SUM(t.lines_of_code) - 1 AS 'Total No of Lines in code ' FROM ( SELECT o.name AS sp_name, (LEN(c.text) - LEN(REPLACE(c.text, CHAR(10), ''))) AS lines_of_code, CASE WHEN o.xtype = 'P' THEN 'Stored Procedure' WHEN o.xtype IN ('FN', 'IF', 'TF') THEN 'Function' END AS type_desc FROM sysobjects o INNER JOIN syscomments c ON c.id = o.id WHERE o.xtype IN ('P', 'FN', 'IF', 'TF') AND o.category = 0 AND o.name NOT IN ('fn_diagramobjects', 'sp_alterdiagram', 'sp_creatediagram', 'sp_dropdiagram', 'sp_helpdiagramdefinition', 'sp_helpdiagrams', 'sp_renamediagram', 'sp_upgraddiagrams', 'sysdiagrams') ) t
Output of above query
We can use script as it is in your Database to get required result.
Hope you will like this post on How to find Number of lines of Code in Database .
If you really like reading my blog and understood at lest few thing then please don’t forget to subscribe my blog .
If you wan daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog
Where todays links are
You may also find following interesting post :
For More information related to BI World visit my Mentalist Blog
Link Resource Blog >> Daily Interesting links
SQL Server Mentalist >> SQL Learning Blog
Business Intelligence Mentalist >> BI World
Connect With me on
Posted by Vishal Pawar
Tags:
Mobile Site | Full Site
Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.