Competition: What’s your favorite Redgate tool? Enter now.

Invalid Objects creates incorrect ALTER script

mjharpermjharper Posts: 26
edited December 30, 2010 8:43AM in SQL Prompt Previous Versions
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.
CREATE PROCEDURE dbo.myTestProc
AS
SELECT *
FROM dbo.nonExistantObject
GO

EXEC sp_rename 'myTestProc' , 'myNewTestProc'

GO


Regards,

Matt
Matt

Comments

  • Hi Matt,

    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
    Paul Stephenson
    Project Manager, Red Gate
Sign In or Register to comment.