Filtering list of stored procedures

  • Hi,

    I can get list of stored procedures using

    select * from information_schema.routines.

    How can I filter out the system procedures.

    Thanks

    Dinuj


    Thanks and Regards,

    Dinuj Nath

  • Something along these lines should work:

    select * from information_schema.routines

    where

    objectproperty(object_id(routine_name),'IsMSShipped')=0

    and routine_name not like 'r_%'

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks Frank, but why "routine_name not like 'r_%'" is needed? Why is the first where clause not enough?


    Thanks and Regards,

    Dinuj Nath

  • select * from information_schema.routines where Specific_Name not like 'dt%'




    My Blog: http://dineshasanka.spaces.live.com/

  • I've added this, since I am not interested in those procedures. It's not actually needed. If you don't use it, you'll get the same result as Dinesh.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Try this from sysobjects ( another alternative )-

    SELECT *

     FROM sysobjects

     WHERE xtype = 'p'

       AND category != 2

     ORDER BY name

    ~~~~~~~~~~~~
    Sailesh Mishra

  • Sure, this works, but you know that you should prefer using the INFORMATION_SCHEMA views instead of direct querying the system tables if you can?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks everyone. Frank, You mean to say there are some system procedures which begin with 'r_'. Will Dinesh's solution work? I mean shouldn't it be 'dt_%' not 'dt%' or is it that anything that starts with 'dt' is considered system procedure. I had figured out the 'dt_%' part, that is why I posted this question on the first place.

    Thanks

    Dinuj


    Thanks and Regards,

    Dinuj Nath

  • Dinesh's solution will work.

    dt% implies dt_%. So as long as your own naming convention doesn't use dt as beginning, it really shouldn't matter what you use.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 9 posts - 1 through 8 (of 8 total)

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