Thursday, August 12, 2021

Buggish: Microsoft SQL SP Rename for SMO TextHeader and ScriptHeader

 Background: I use SMO to promote objects from one database to another.

Issue: I get error "The name specified in the TextHeader property of StoredProcedure 'StoredProcedureName' must match Name property."

Cause: The one cause I found related to this is when a developer renames the stored procedure. I am assuming they use the sp_rename function. For some reason, this proc does not update the TextHeader or the ScriptHeader. When pulling these properties, these still reference the old name. In my old post, this was a speculation. The reason I found this was because this specific promotion includes renaming an existing stored procedure. In the past, my best guess is that they renamed during development so never needed to submit a rename change in higher environments.

Workaround: My fix is to use SSMS to get the alter stored procedure and execute as is. This unfortunately updates the updated date, but better than being stuck.

Fix request: When renaming object, make sure to update other properties that references the old name like TextHeader and ScriptHeader. 


Reference

https://douglastclee.blogspot.com/2020/09/buggish-c-smo-error-name-specified-in.html

No comments:

Post a Comment