Tuesday, June 9, 2009

use of cursor to print all Stored procedure of Database

DECLARE @procName varchar(100)

DECLARE RetProcName CURSOR FOR select [Name] from sysobjects where type='P'

OPEN RetProcName

FETCH NEXT FROM RetProcName INTO @procName

WHILE @@FETCH_STATUS = 0

BEGIN

exec sp_helptext @Procname

-- print

Fetch NEXT FROM RetProcName INTO @procName

END

CLOSE RetProcName

DEALLOCATE RetProcName

No comments:

Post a Comment