Я использую это для работы. оставьте [] в поле @TEXT, похоже, хотите вернуть все ...
SET NOCOUNT ON
DECLARE @TEXT VARCHAR(250)
DECLARE @SQL VARCHAR(250)
SELECT @TEXT='10.10.100.50'
CREATE TABLE #results (db VARCHAR(64), objectname VARCHAR(100),xtype VARCHAR(10), definition TEXT)
SELECT @TEXT as 'Search String'
DECLARE #databases CURSOR FOR SELECT NAME FROM master..sysdatabases where dbid>4
DECLARE @c_dbname varchar(64)
OPEN #databases
FETCH #databases INTO @c_dbname
WHILE @@FETCH_STATUS -1
BEGIN
SELECT @SQL = 'INSERT INTO #results '
SELECT @SQL = @SQL + 'SELECT ''' + @c_dbname + ''' AS db, o.name,o.xtype,m.definition '
SELECT @SQL = @SQL + ' FROM '+@c_dbname+'.sys.sql_modules m '
SELECT @SQL = @SQL + ' INNER JOIN '+@c_dbname+'..sysobjects o ON m.object_id=o.id'
SELECT @SQL = @SQL + ' WHERE [definition] LIKE ''%'+@TEXT+'%'''
EXEC(@SQL)
FETCH #databases INTO @c_dbname
END
CLOSE #databases
DEALLOCATE #databases
SELECT * FROM #results order by db, xtype, objectname
DROP TABLE #results