我的数据库中有很多存储过程,很难找到#myTemp
表的使用位置。
是否有任何查询可以搜索所有存储过程中的文本?
例如:
select...
where text like '%myTemp%'
我想找到一个下面的Sql查询,其中使用了存储过程。
exec sp_executesql N'SELECT
[ProcInstID],
"Process Name" AS Workflow,
"Source",
CONVERT(DATETIME, CASE WHEN ("Receipt Date" <> ''1/1/0001 12:00:00 AM'' AND "Receipt Date" IS NOT NULL) THEN "Receipt Date" END, 101) AS ReceiptDate
INTO
#MyTempTable
FROM
(SELECT [ProcInstID......
答案 0 :(得分:2)
如果您只需要搜索存储过程,可以使用以下查询
select obj.name, mo.definition
from sys.sql_modules mo
inner join sys.objects obj on obj.object_id = mo.object_id
where type = 'P' and definition like '%#myTemp%'
答案 1 :(得分:1)
您可以从sys.sql_modules
中进行选择select OBJECT_NAME(object_id) as ObjectName
from sys.sql_modules
WHERE Definition like '%myTemp%'
答案 2 :(得分:1)
select distinct object_name(id)
from syscomments
where text like '%[ABD]%'
order by object_name(id)