hi friends,
Would you like to tell me that I want a query that returns a list of all the (user) stored procedures in a database by name, with the number of lines of code for each one.
Query to show all stored procedure with their code
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

NarayanRank #8,477 · 221 reputationPosted Nov 23, 2011, 3:57 PM EST
Select Name,OBJECT_DEFINITION(object_id) from sys.procedures
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 23, 2011, 6:00 PM EST
Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 23, 2011, 7:12 PM EST
if you want number of line along with spname and code then use below code....
create 1 user defined function like below which return you count of line of spname you passed
and call that function in select clause..........
create FUNCTION [dbo].[CountOfLine]
(
-- Add the parameters for the function here
@SPNAME varchar(max)
)
RETURNS TABLE
AS
RETURN
(
create table #tempcnt(code varchar(max))
insert into #tempcnt exec sp_helptext @SPNAME
select count(*) from #tempcnt
)
and write query like below
Select Name,OBJECT_DEFINITION(object_id) as Code,NumberOFLine= dbo.CountOfLine(Name)
from sys.procedures
Thanks,
Pravin.