Hi ,
How can we find a particular stored procedure. I need to find a stored procedure which I don't know is in which database. Can somebody please, help with a script.
Thanks
Hi ,
How can we find a particular stored procedure. I need to find a stored procedure which I don't know is in which database. Can somebody please, help with a script.
Thanks
Which database server? With MS SQL Server, you can use sp_help 'procname'.
If it is Sql Server 2005 you can use
SELECT * FROM Sys.Objects where Name = 'YOUR_NAME_HERE' AND type = 'P'
It will tell you if the procedure is in a particular database.
Which SQL? SQL 2k/2k5/2k8 has management studio which lets you browse. Expand Databases/Database/Programmability/Stored Proceudres
Replace text to search for with your string and this will search all databases on your server.
exec sp_MSforeachdb 'SELECT db=''?'', [type], [name], [text] FROM [?]..sysobjects a inner join [?]..syscomments b on a.id = b.id where text like ''%Text to search for%'' order by [name], [number]', '?'
One way by using the ANSI information_schema.routines view, change ProcNameHere to the name you want
select * from information_schema.routines
where routine_type = 'PROCEDURE'
and specific_name = 'ProcNameHere'