SQL Server and TFS - How to rename stored procedures
This question isn't so much about how to RENAME a stored procedure, as it is asking about how to MERGE the RENAME to other branches in TFS.

As pointed out by Dan Guzman in the comments, the Refactor &gt; Rename feature while editing a SQL file should be used:



(note that this is not an option if you right-click the file; you have to right click the entity name in the file (or have the caret on the name and use the shortcut chord))

The hard part is now merging the rename between branches.

Using either the MERGE command from Source Control Explorer or the unshelve /migrate command to TFS Power Tools (tfpt.exe), the pending changes are generated as a DELETE and an ADD which deletes the link to the TFS history!

Furthermore, your .sqlproj file will be a giant headache to merge conflicts this way.

Instead, the renamed files should be manually renamed in the target branch, then the TFS Power Tools unshelve /migrate command will just require merging the file contents as normal, with the .sqlproj file already having the changes made to it (so you can choose the Keep target branch version option on it, presuming you don't have other ADD or DELETE changes additional to the RENAME changes).

There seems to be another method using labels, but the gated check-in process is a contraindication to it.

Note that if you start getting this error message renaming files, immediately restart Visual Studio and manually fix the .sqlproj file in a text editor as the file was renamed on disk but not in the project file:



To recap, this is the process I have found to work the best:


Manually perform all the renames in the target branch
Ensure changes in the source branch are in a shelfset
Use the TFS Power Tools unshelve /migrate command
Verify. Verify. Verify. And also verify by using this advanced publish option:




I hope this helps somebody, as this process has been a serious headache for me because I have to merge to multiple branches, and my changeset is very large.