PRB: Renaming Stored Procedure, View or Trigger Does Not Update SYSCOMMENTS Table (243198)
The information in this article applies to:
- Microsoft SQL Server 6.5
- Microsoft SQL Server 7.0
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q243198 SYMPTOMS
Renaming a Stored Procedure, View or Trigger object will not change the name of the corresponding Stored Procedure, View or Trigger object in the SYSCOMMENTS table. This may cause problems when a script is generated for the renamed object. The script for the renamed object is generated with the old name of the object in the CREATE statement.
For example, you can rename a stored procedure from the Enterprise Manager or SQL Server Query Analyzer with these steps:
- From Enterprise Manager, expand the database folder and select Stored Procedures. Right-click the stored procedure and then select RENAME.
- From SQL Server Query Analyzer, select the stored procedure's database name in the database window and type in sp_rename 'old name','new name'.
A renamed Stored Procedure, View or Trigger is upgraded to SQL Server 7.0 with the old name of the object. The Upgrade Wizard moves SQL Server 6.x databases to SQL Server 7.0. An upgrade script is created based on the syscomments entries in the 6.x database. It is recommended that you drop and recreate objects that have been renamed prior to upgrading SQL Server to version 7.0. An example of the warning you receive during the SQL Server 6.5 to SQL Server 7.0 upgrade process follows:
=============================================
The following syscomments entries are invalid on your 6.x SQL Server. It is
recommended that you fix these problems before you continue.
=============================================
********************************
mydb
********************************
********************************
Inconsistency Report For Database: mydb.
********************************
dbo.renamedmytest
Procedure
Object Renamed: Text does not match sysobjects.
--------------------------------
CAUSE
Internally, SQL Server uses the object_id, which remains the same even if the name of the object has changed through RENAME.
WORKAROUND
Do not rename Stored Procedures, Views, or Triggers. Instead, create a script of the existing object, change the name of the object in the CREATE statement of the script, and save the script. The script should now have a DROP statement with the old object name to be dropped. The script should also have the CREATE statement with the new object name. Run the script to create the object with the new name.
Modification Type: | Major | Last Reviewed: | 11/14/2003 |
---|
Keywords: | kbprb KB243198 |
---|
|