Query to get the lines of code of sql objects in ms sql server
Please Enter object Name in place of 'StoredProcedureName'
SELECT t.sp_name,
Sum(t.lines_of_code) - 1 AS lines_ofcode,
t.type_desc
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 IN ( 'StoredProcedureName' )) t
GROUP BY t.sp_name,
t.type_desc
ORDER BY 1
Thanks,
Dinesh Babu
No comments :
Post a Comment