Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Find all Procedures, Views, Functions that have been renamed

By David Hay,

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.

 

http://support.microsoft.com/kb/243198

 

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.

 

 

Total article views: 760 | Views in the last 30 days: 1
 
Related Articles
FORUM

Rename() broken?

After renaming an object (e.g. user defined function), the Script() method will not work as expected...

FORUM

Scripting Objects Including Permissions

Scripting Objects Including Permissions

FORUM

renaming tables from script

is it possible to script a rename of all tables and database name?

FORUM

SSIS script object

Script object Design Script does not open up script editor

FORUM

Generating Scripts for Database Objects

Creating Seperate Scripts Per Object

Tags
functions    
procedures    
sp_rename    
syscomments    
views    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones