How to list all stored procedure from the SQL Server database?

Raja
Posted by Raja under Sql Server category on | Views : 6011
To list all user stored procedure from the database, use following code.

SELECT name FROM sys.procedures


To print all name of the stored procedure using Cursor, use following code

DECLARE @name VARCHAR(50) -- database name  
DECLARE db_cursor CURSOR FOR

SELECT name FROM sys.procedures;

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
print @name
--sp_helptext ''+ @name + ''

FETCH NEXT FROM db_cursor INTO @name
END

CLOSE db_cursor
DEALLOCATE db_cursor

Comments or Responses

Posted by: Deeraj on: 1/6/2009 Level:Starter | Status: [Member]

In Sql Server 2005:

Select top 1 routine_name,* from information_schema.routines

Login to post response