我非常尴尬,但我记不起MS SQL Server SP的名称,它在您的数据库中搜索指定的文本字符串,并返回包含该字符串的所有表名,函数,存储过程等。我无法在帮助中查找,因为为了获得帮助,你需要知道它的名字!它类似于sp_findtext
。
它叫什么?
来吧,最快的手指获得回复信用! :)
答案 0 :(得分:2)
我找到了一个自定义的SP(FindTextInDatabase),它完全按照以下方式执行:
http://geekswithblogs.net/ram/archive/2007/05/22/112672.aspx
不知道是否还有现成的程序。如果有的话,我也找不到它。
答案 1 :(得分:2)
来自http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32319
CREATE PROCEDURE sp_FindText @text varchar(8000), @findtype varchar(1)='P' AS
SET NOCOUNT ON
IF @findtype='P' SELECT DISTINCT Len(SubString(text,1, PatIndex('%' + @text + '%', text)))-Len(Replace(SubString(text,1, PatIndex('%' + @text + '%', text)),char(13),''))+1 AS Line,
--PatIndex('%' + @text + '%', text) AS Position,
OBJECT_NAME(id) AS ProcName
FROM syscomments
WHERE text like '%' + @text + '%'
ORDER BY ProcName, Line
IF @findtype='C' EXEC('SELECT TABLE_NAME + ''.'' + COLUMN_NAME AS TableColumn FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE ''%' + @text + '%'' ORDER BY TableColumn')
IF @findtype='T' EXEC('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ''%' + @text + '%'' ORDER BY TABLE_NAME')
GO
它不仅搜索过程和视图定义文本,还会查找表,视图和列名称:
EXEC sp_FindText 'myTable' --or-- EXEC sp_FindText 'myTable', 'P' --finds procedures/views containing 'myTable' in their definition/code
EXEC sp_FindText 'myTable', 'T' --finds tables/views containing 'myTable' in their name
EXEC sp_FindText 'myCol', 'C' --finds columns containing 'myCol' in their name
答案 2 :(得分:0)
快速检查一下这些结果:
select * from sysobjects where [name] like 'sp_%' order by 1
select * from master..sysobjects where [name] like 'sp_%' order by 1
你找到适合自己的东西。
干杯!