Home  >  Article  >  Database  >  存储过程 或视图的字符串查询

存储过程 或视图的字符串查询

WBOY
WBOYOriginal
2016-06-07 17:44:141005browse

存储过程查询 SELECT a.name,b.text FROM sys.procedures a LEFT JOIN sys.syscomments b ON a.object_id = b.id WHERE b.text LIKE '%DEMO.DBO.RFI_StartOpr%' 视图查询 SELECT a.name,b.text FROM sys.views a LEFT JOIN sys.syscomments b ON a.object_id

存储过程查询

SELECT a.name,b.text FROM sys.procedures a LEFT JOIN sys.syscomments b ON a.object_id = b.id WHERE b.text LIKE '%DEMO.DBO.RFI_StartOpr%'

视图查询

SELECT a.name,b.text FROM sys.views a LEFT JOIN sys.syscomments b ON a.object_id = b.id WHERE b.text LIKE '%COPTD%'

 

CREATE TABLE #Proc 

(

procname VARCHAR(200),

CONTENT VARCHAR(max) 

)

DECLARE @procname VARCHAR(200)

DECLARE @temp VARCHAR(max) 

DECLARE selectproc  CURSOR  SCROLL FOR

SELECT name FROM sys.procedures 

OPEN selectproc

FETCH NEXT FROM selectproc INTO @procname 

WHILE @@FETCH_STATUS = 0

BEGIN

EXEC @temp = sp_helptext [PROC_MULKEY_Save_MultiOperQty]

PRINT @temp

INSERT #Proc ( procname, CONTENT )

VALUES  ( @procname, @temp )  

FETCH NEXT FROM selectproc INTO @procname 

END

CLOSE selectproc

DEALLOCATE selectproc

SELECT * FROM #Proc WHERE CONTENT LIKE '%DEMO.DBO.RFI_StartOpr%'

--DROP TABLE #Proc

,网站空间,香港空间,香港虚拟主机
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn