Click here to Skip to main content
14,599,519 members

Get List of Extended storedProcedures that are Allowed to you for Common Use

Rate this:
4.80 (25 votes)
Please Sign up or sign in to vote.
4.80 (25 votes)
26 Jul 2009CPOL
An easy way to get a list of extended storedProcedure allowed to you for common use

Introduction 

For how many extended storedProcedures do you have the permission to use as public in your own SQL queries / storedProcedure as well? This simple article will show you all the extended storedProcedures allowed to you for common use.

Background  

A couple of months ago, I needed to work with SQL server extended storedProcedure, where I found some extended storedProcedures which are not allowing properly to perform some task.

That’s why I tried to get a list of all extended storedProcedures which are available to you for common use.

Using the Code 

It’s a very simple method. I just use the sysobjects and syspermissions system tables from the master database. The table definitions are as follows:

sysobjects  

Contains one row for each object (constraint, default, log, rule, stored procedure, and so on) created within a database. In tempdb only, this table includes a row for each temporary object.

More details will be available from this link

syspermissions

Contains information about permissions granted and denied to users, groups, and roles in the database. This table is stored in each database.

More details will be available from this link.

Example script is given below: 

-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <Author,,Md. Marufuzzaman>
-- Create date: <Create Date,,02/01/2009>
-- Description:    <Description,,>
-- =============================================
--EXEC spGetPUBLIC_EXProcedure

CREATE PROCEDURE [dbo].[spGetPUBLIC_EXProcedure]
AS
BEGIN

    SELECT     TOP (100) PERCENT SystemObject.name AS [Extended storedProcedure]
             , USER_NAME(SystemPermissionObject.grantee) AS [Granted to]

    FROM    master.dbo.sysobjects AS SystemObject
            INNER JOIN master.dbo.syspermissions AS SystemPermissionObject
            ON SystemObject.id = SystemPermissionObject.id

    WHERE   (SystemObject.type = 'X')
    ORDER BY SystemObject.name

END

GO

Conclusion

I hope that this article might be helpful to you. Enjoy!

History

  • 26th July, 2009 : Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


Comments and Discussions

 
GeneralMy vote of 5 Pin
Member 1051082210-Feb-12 23:18
professionalMember 1051082210-Feb-12 23:18 
QuestionIs this possible to ceate a dynamic storedProc? Pin
Аslam Iqbal27-Jul-09 5:40
professionalАslam Iqbal27-Jul-09 5:40 
AnswerRe: Is this possible to ceate a dynamic storedProc? Pin
Md. Marufuzzaman27-Jul-09 6:29
professionalMd. Marufuzzaman27-Jul-09 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Article
Posted 26 Jul 2009

Stats

34.4K views
25 bookmarked