Does anyone have a valid method in referencing system information to search for a stored procedure across all databases in a SQL Server 2000 instance? I am currently tasked with migrating crystal reports to SSRS and the customer has roughly 500 or more crystal reports with stored procedures spread over multiple databases. I know I can filter each database's programmability folder by text but I was looking for an outcome in which I can query master.dbo.sysdatabases and reference that to syscomments in which I can specify text and find a stored procedure tied to a database.
Sql-server – Referencing a stored procedure by a name description across all databases in a SQL Server 2000 Instance
sql-server-2000ssrsstored-procedures
Related Question
- Sql-server – How to change a user’s name in SQL Server 2000
- Sql-server – SQL Server 2000 DTS package, filter rows using stored procedure returned date
- Sql-server – Scheduled stored procedure on all databases in the server
- Sql-server – Random performance of stored procedure across databases
- Sql-server – Migrating SQL Server 2000 to 2008/14 – Stored procedures compatibility
Best Answer
Just use a cursor to loop through the databases and query the sysobjects table:
(Cursor code not included.) Or use the (undocumented)
sp_MSforeachdb
:(don't split that over two lines, though)
Also, sp_MSforeachdb has known issues, like failing on very long database names, so I usually prefer the cursor.