Invalid Objects creates incorrect ALTER script
mjharper
Posts: 26
Hi
I have just been using the "Find Invalid Objects" functionality. When I view the ALTER script for some objects the script is incorrect. The object name it uses seems to be the original name I gave the object, but I have since updated the name using SP_RENAME.
Here's a script to explain what I mean - it creates a new SP referencing an object that doesn't exist. Then I change the name of the SP. The ALTER script that SQL Prompt will produce will still use the original SP name.
Regards,
Matt
I have just been using the "Find Invalid Objects" functionality. When I view the ALTER script for some objects the script is incorrect. The object name it uses seems to be the original name I gave the object, but I have since updated the name using SP_RENAME.
Here's a script to explain what I mean - it creates a new SP referencing an object that doesn't exist. Then I change the name of the SP. The ALTER script that SQL Prompt will produce will still use the original SP name.
CREATE PROCEDURE dbo.myTestProc AS SELECT * FROM dbo.nonExistantObject GO EXEC sp_rename 'myTestProc' , 'myNewTestProc' GO
Regards,
Matt
Matt
Comments
Thanks for your bug report. I can confirm I've reproduced your issue, and that neither the Refresh button, the Refresh Suggestions option nor closing and opening SSMS makes the correct script appear for myNewTestProc.
The issue is logged as SP-2927 in our internal bug-tracking system.
If the SP is redefined as ALTER PROCEDURE dbo.myNewTestProc ... then the Script as ALTER button works again. Also, note that if you use SQL Prompt 5's Smart Rename feature to rename the procedure then this issue does not arise.
Regards,
Paul
Project Manager, Red Gate