如何找到包含<text>的存储过程?

本文翻译自:How do I find a stored procedure containing ?

我需要在SQL Server 2008中搜索包含数据库字段名称或变量名称的存储过程。


#1楼

参考:https://stackoom.com/question/ljoJ/如何找到包含-text-的存储过程


#2楼

In case you needed schema as well: 如果您还需要架构:

SELECT   DISTINCT SCHEMA_NAME(o.schema_id),o.name,[text]
FROM     syscomments AS c
         INNER JOIN sys.objects AS o ON c.id = o.[object_id]
         INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id
WHERE    text LIKE '%foo%'
ORDER BY  SCHEMA_NAME(o.schema_id),o.name 

#3楼

You can also try ApexSQL Search - free SSMS plug-in from ApexSQL. 您还可以尝试从ApexSQL免费获得ApexSQL Search SSMS插件。

在此输入图像描述


#4楼

SELECT s.name + '.' + o.name ProcedureName
, c.text ProcedureSteps
FROM   sys.syscomments c 
INNER JOIN
sys.objects o 
ON 
c.id = o.object_id
INNER JOIN
sys.schemas s 
ON 
o.schema_id = s.schema_id
WHERE  o.type = 'P'
AND c.text LIKE N'%XXXX%'
ORDER BY s.name + '.' + o.name
, c.colid

This query returns the name and the content of any stored procedure where "XXXX" is is referenced within the stored procedure. 此查询返回存储过程中引用“XXXX”的任何存储过程的名称和内容。

This is quit usefull when finding procedures that reference a specific table/view/procedure 在查找引用特定表/视图/过程的过程时,这是有用的


#5楼

select * from sys.system_objects
where name like '%cdc%'

#6楼

SELECT * FROM sys.procedures WHERE Name LIKE '%CompanySpecialisation%'

这是我在SQL 2012中编写的选择所有存储过程的地方,例如“CompanySpecialisation”这样的名称

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值