SQL query all stored procedures (Stored Procedure)

Source: Internet
Author: User
SQL query all stored procedures (Stored Procedure)

 

 

Information_schema.routines View

Requirements: Microsoft SQL Server 2000 or later

You can use the information_schema.routines view to retrieve information about stored procedures. This view contains one row for each stored procedure accessible to the current user in the current database.

For example, the following query returns owner, name and definition text of stored procedures in the current database:

 

Select routine_schema, routine_name, routine_definition
From information_schema.routines
Where routine_type = 'processed'

 

The information_schema.routines view was introduced in SQL Server 2000. This view is based on the sysobjects, syscomments and other system tables.

To retrieve the same information about stored procedures from a Microsoft SQL Server 7.0 database, you can use the following query:

 

Select Su. Name, so. Name, SC. Text
From sysobjects so, syscomments SC, sysusers Su
Where xtype = 'p' and so. ID = SC. ID and so. uid = Su. uid
Order by SU. Name, so. Name, SC. colid

 

The query above may return several rows per each stored procedure if the definition text is longer than 4000 characters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.