Search for a string throughout SQL Server database.
Query finds all the database objects which contain a specific string (which you assign to @SEARCHSTRING variable)Declare @SEARCHSTRING VARCHAR(255) SELECT @SEARCHSTRING = 'YOUR_SEARCH_STRING' SELECT DISTINCT sysobjects.name AS [Object Name] , case when sysobjects.xtype = 'P' then 'Stored Proc' when sysobjects.xtype in ('FN', 'TF') then 'Function' when sysobjects.xtype = 'TR' then 'Trigger' when sysobjects.xtype = 'V' then 'View' end as [Object Type], sysobjects.xtype FROM sysobjects,syscomments WHERE sysobjects.id = syscomments.id --AND sysobjects.type in ('P','TF','TR','V','FN') AND sysobjects.category = 0 AND CHARINDEX(@SEARCHSTRING,syscomments.text)>0
No comments:
Write comments