Allow login to view information_schema views?

  • ChrisMoix-87856


    Points: 7288

    I would like to be able to let our developers query the information_schema views (like information_schema.routines) in some of our production databases. Right now, it only let's them see objects that they have permissions to...

    i.e. if they have been granted execute on a procedure, they can see it in the view, and they can;t see any other user created procedures, even those in the dbo schema.

    This is interesting becauase they can do a sp_helptext on any procedure, but they can't retrieve a listing of the procedures from the information_schema.routines view.

    I've googled this, but I can't find anything that tells me how to allow them to query the views. Any ideas?

    More info: I created a SQL login and it is in the public server role. I added itas a user to a database, and put it in the public and db_datareader database role. Still can't see anything in information_schema.routines except for about 30 dt_ routines.


  • Ron McCullough

    SSC Guru

    Points: 63877

    It has been 7 hours since you posted your question with no answers.

    Let me ask:

    Have you looked at:



    and / or the "Execute As"


    subjects in Books on Line?.. It not they may give you some sort of a hint as to how to do what you want to do.

    If everything seems to be going well, you have obviously overlooked something.


    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • ChrisMoix-87856


    Points: 7288

    Neither of those choices will allow a user without execute rights to a stored procedure to find it in a listing by querying information_schema.routines or sysobjects.

    This is stemming from having developers that need to be able to do an sp_helptext on stored procedures in our production system, but they should not have execute rights. I've just been tasked with finding a solution, not determining the 'why' behind the need for it.

    I still think it is odd that these logins can do a sp_helptext on a specific stored procedure, but they can't run a select * from information_schema.routines and get a listing including that procedure without having execute permissions on the procedure. I know it's more secure that way, but that doesn;t help when people are saying - "I could do it on SQL Server 2000"

  • Lowell

    SSC Guru

    Points: 323450

    i thought if you create a group, and add this command, then your developers, if they belong to that group, can view the definition of any of the objects int he database, but since they are not datareaders or datawriters, they can't fiddle with the data:

    Grant View Any Definition To MyUserGroup


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Adi Cohn-120898


    Points: 33944

    You can create a stored procedure and use the execute as clause. In then you can grant permissions to use this procedure to anyone that needs to be able to see all the procedures. Here is the example:

    create procedure ShowAllPorcedures

    with execute as self


    select * from information_schema.routines


    grant execute on ShowAllPorcedures to public


    To know how to ask questions and increase the chances of getting asnwers:

    For better answers on performance questions, click on the following...

  • ChrisMoix-87856


    Points: 7288

    Lowell's suggestion worked beautifully. Thanks.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply