I posted about sp_findsp previously and decided to revisit it. I didn't write it (see previous post for credit/link) but I did add a bit to it. First, I cleaned it up a bit to make it easier to read, and second, I made it so that it is a system proc so I could access it from any db on my server. I may end up doing some cleanup on it's output, but that's all I had time for for now. So here goes, the new version!
USE masterGOPRINT 'Checking for the existence of this procedure'IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL --means, the procedure already existsBEGINPRINT 'Procedure already exists. So, dropping it'DROP PROC sp_findspENDGOCREATE PROC sp_findsp @s varchar(255) ASBEGIN DECLARE @msg varchar(255) ,@ul varchar(255) SELECT @s='%' + @s + '%' SELECT 'SP Name'=upper(o.name), Seq=colid ,'SP Line'=substring(text,patindex(@s,text)-5, 30) FROM syscomments c , sysobjects o WHERE o.id=c.id and patindex(@s,text) > 0 ORDER BY [name] SELECT @msg='* Stored procedures containing string "' + @s + '=' + convert(varchar(8),@@rowcount) + ' *' SELECT @ul=replicate('*',datalength(@msg)) PRINT ' ' PRINT @ul PRINT @msg PRINT @ulENDGO --Mark procedure as system objectEXEC sys.sp_MS_marksystemobject sp_findspGOPRINT 'Granting EXECUTE permission on sp_findsp to all users'GRANT EXEC ON sp_findsp TO publicGO
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail