MsSQL Find Usages Table Or Stored Procedure

MsSQL Find Usages Table Or Stored Procedure,第1张

概述MsSQL Find Usages Table Or Stored Procedure

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

CREATE PROCEDURE [dbo].[sp_FindUsages]	(@Objectname SYSname)  ASBEGIN		SET NOCOUNT ON;	CREATE table #Result([ID] INT IDENTITY,[Objectname] VARCHAR(100),[line] INT,[Text] NVARCHAR(max));		DECLARE @ID INT;	DECLARE @line INT;	DECLARE @name NVARCHAR(1024);	DECLARE pl CURSOR FOR SELECT [name] FROM sys.procedures;	OPEN pl;	FETCH NEXT FROM pl INTO @name;	WHILE @@FETCH_STATUS = 0 	BEGIN				EXEC ('INSERT INTO #Result ([Text]) EXEC sp_helptext ' + @name);		SET @line = 7;		DECLARE r CURSOR FOR SELECT ID FROM  #Result WHERE Objectname IS NulL;			OPEN r;		FETCH NEXT FROM r INTO @ID;		WHILE @@FETCH_STATUS = 0 		BEGIN			SET @line = @line + 1;			UPDATE #Result SET line = @line,Objectname = @name WHERE ID = @ID ;			FETCH NEXT FROM r INTO @ID;		END 		CLOSE r;		DEALLOCATE r;			FETCH NEXT FROM pl INTO @name;	END 	CLOSE pl;	DEALLOCATE pl;	SELECT * FROM #Result WHERE [Text] liKE '%' + @Objectname + '%';	DROP table #Result;END--exec [sp_FindUsages] [spname]

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的MsSQL Find Usages Table Or Stored Procedure全部内容,希望文章能够帮你解决MsSQL Find Usages Table Or Stored Procedure所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1164894.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存