On an MS SQL Server 2000 installation I have numerous stored procedures that pull data from databases other than the one it's stored in. All selects occur on the same database server. For example:
select * from [OtherDatabase]..table
How can I find which procedures do that sort of thing without eyeballing each one?
The following is a stored proc that will search for text contained in any stored proc. You could use this to search for the various databases that might get called.
CREATE PROCEDURE FindTextInSP
@StringToSearch varchar(100)
AS
SET @StringToSearch = '%' +@StringToSearch + '%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @stringtosearch
ORDER BY SO.Name
GO