欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2022-04-08 12:45:11
...

存储过程查询 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

,网站空间,香港空间,香港虚拟主机