MSSQL · keyword in query stored procedure

Time:2021-6-13
Reading time |0.22 min word count |408 characters
primary coverage |1. Introduction & background
“MSSQL · query keywords in stored procedures”
Author | SCscHero Writing time | 2021/5/15 PM11:30
Article type |Series Completion |Completed
motto Every great cause has a trivial beginning.

1、 Introduction & background    Completion: 100%


a) Coping with problems & scenarios

  1. Which stored procedures exist according to a keyword?
  2. Query which stored procedures exist according to the fields of a table?

b) Solution principle & method

--Find a stored procedure with a keyword
SELECT OBJECT_NAME(ID),ID FROM SYSCOMMENTS
WHERE ID IN
( SELECT OBJECT_ID(NAME) FROM DBO.SYSOBJECTS WHERE XTYPE='p'
)
And text like '% keyword%'

--Find a stored procedure with a keyword:适用于SQL Server2005/2008
SELECT DISTINCT B.NAME
FROM DBO.SYSCOMMENTS A, DBO.SYSOBJECTS B
Where a.id = b.id and b.xtype ='p 'and a.text like'% keyword% '
ORDER BY NAME

2、 Statement and references    Completion: 100%


Original blog, please do not reprint without permission.

If you have any help, you are welcome to like, collect and pay attention. If you have any questions, please comment! If you need to contact the blogger, you can directly send a private message to scscshero.