show-notice
hide-notice

Wednesday, 17 July 2013

How to Use of Cursor to Print All Stored Procedures of Database


Introduction

I will explain How to Use of Cursor to Print All Stored Procedures of Database.
Example

USE gohil
GO
DECLARE @procName
VARCHAR
(100)
DECLARE @getprocName CURSOR
SET @getprocName = CURSOR FOR
SELECT s.name FROM sysobjects s
WHERE type = 'P'
OPEN @getprocName
FETCH NEXT
FROM @getprocName
INTO
@procName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_HelpText
@procName
FETCH NEXT
FROM @getprocName
INTO
@procName
END
CLOSE @getprocName
DEALLOCATE @getprocName
GO
 
Just give this script a try and it will print text of all the SP in your database. If you are using Grid View for Result Pan I suggest to change it to Text View (CTRL+T) to read the text easily.

SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com