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.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pravin MorePosted Nov 24, 2011, 12:12 AM
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.
Satyapriya NayakPosted Nov 23, 2011, 11:00 PM
NarayanPosted Nov 23, 2011, 8:57 PM
Select Name,OBJECT_DEFINITION(object_id) from sys.procedures