SQL Server searches for all stored procedures that contain a specific text.

Source: Internet
Author: User
I want to find all the stored procedures that use sp_a. Right-click the sp_a-viewdependencies-select viewobjectsthatdependon [sp_a] and you will find that sometimes the results cannot be listed in all, not all other stored procedures that use sp_a.

I want to find all the stored procedures that use sp_a. Right-click the sp_a-view dependencies-select view objects that depend on [sp_a] and you will find that sometimes the results cannot be listed in all, not all other stored procedures that use sp_a.

That's all.

The stored procedure calls mup_GetA (I erased the project-related names)

You can view objects dependent on mup_GetA through the functions provided by sqlserver graphics manager.

The result is a bit confusing. I didn't list mup_GetB (I used SQL server 2005)


The solution is as follows:
Method 1:
Choose Database Management> right-click Database> tasks> Generate Scripts> .....
Export all stored procedures to the file, and then ctrl + F to find
Method 2:
The Code is as follows:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '% text %'
AND ROUTINE_TYPE = 'processed'

Replace text with the content you want to find

Method 3:
The Code is as follows:
Select name
From sysobjects o, syscomments s
Where o. id = s. id
And text like '% text %'
And o. xtype = 'P'

Replace text with the content you want to find

Finished

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.