We have had a standard practice of using sp_rename on procedures when moving code for years. This is now causing issues when we want to automate some processes of scripting in/out certain objects.
This will return database, object id, object name, and the first 50 of syscomments where the object name is not found in the 1st block of syscomments. It's ugly and a kludge but it works. Anyone care to expand on it is more than welcome. I need to add a block for triggers as well as they are defined in syscomments to, but we hardly use them, and doubt we would rename one.
With the list, you can then recreate them with the proper names either via scripting, or SSMS enterprise manager. I just drop them, as they are 99.9% obsolete objects.
Quote from BOL:
Renaming a stored procedure, view or trigger will not change the name of the corresponding object name in the syscomments table. This may result in problems generating a script for the object as the old name
will be inserted from the syscomments table into the CREATE statement. For best results, do not rename these object types. Instead, drop and re-create the object by its new name.