在 SQL Server 中的存储过程中搜索文本 [英] Search text in stored procedure in SQL Server

查看:30
本文介绍了在 SQL Server 中的存储过程中搜索文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我所有的数据库存储过程中搜索一个文本.我使用以下 SQL:

I want to search a text from all my database stored procedures. I use the below SQL:

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc
FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
WHERE m.definition Like '%[ABD]%';

我想在包括方括号在内的所有存储过程中搜索 [ABD],但它没有给出正确的结果.如何更改查询以实现此目的?

I want to search for [ABD] in all stored procedures including square brackets, but it's not giving the proper result. How can I change my query to achieve this?

推荐答案

转义方括号:

...
WHERE m.definition Like '%\[ABD\]%' ESCAPE '\'

然后方括号将被视为字符串文字而不是通配符.

Then the square brackets will be treated as a string literals not as wild cards.

这篇关于在 SQL Server 中的存储过程中搜索文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆