通过在 SQL Server Management Studio 2008 中搜索所有存储过程来查找字符串

发布于 2024-10-25 01:21:43 字数 57 浏览 0 评论 0原文

有没有办法在 SQL Server Management Studio 的所有存储过程中搜索字符串?

Is there a way to search for a string within all stored procs in SQL Server Management Studio?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烙印 2024-11-01 01:21:43
SELECT *
FROM sys.sql_modules
WHERE definition LIKE '%yourstring%'
SELECT *
FROM sys.sql_modules
WHERE definition LIKE '%yourstring%'
霞映澄塘 2024-11-01 01:21:43

Have a look at RedGate's SQL Search. It's a Management Studio plugin and a free download. You can search within a given database or across an entire instance.

牵你的手,一向走下去 2024-11-01 01:21:43

我总是用这个;

SELECT Name
 FROM sys.procedures
 WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%SEARCHSTRING%'

I always use this;

SELECT Name
 FROM sys.procedures
 WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%SEARCHSTRING%'
独﹏钓一江月 2024-11-01 01:21:43

就我而言,每当我搜索特定文本或关键字时,我都希望获取存储过程的架构和名称。我使用且对我有用的代码是:

USE [your_DB_name];
GO
SELECT [Scehma]=schema_name(o.schema_id), o.Name 
FROM sys.sql_modules m
 INNER JOIN sys.objects o
ON o.object_id = m.object_id
WHERE m.definition like '%your keyword%'
GO

结果很简单,如下所示:

----------------------------------------------
|    Schema    |    Name                     |
----------------------------------------------
|    dbo       |  stored_procedure_name      |
----------------------------------------------
...
and so on (if the keyword exists in more than one stored procedure)

In my case, I was looking to get the schema and the name of the stored procedure whenever I search for a specific text or keyword. The code I use and it is working for me is:

USE [your_DB_name];
GO
SELECT [Scehma]=schema_name(o.schema_id), o.Name 
FROM sys.sql_modules m
 INNER JOIN sys.objects o
ON o.object_id = m.object_id
WHERE m.definition like '%your keyword%'
GO

The result is simple and as follows:

----------------------------------------------
|    Schema    |    Name                     |
----------------------------------------------
|    dbo       |  stored_procedure_name      |
----------------------------------------------
...
and so on (if the keyword exists in more than one stored procedure)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文