Undo Checkout succeeded. Compile failed.

When you check out a stored procedure from source control and there are differences between the source control version and the database version, the Show Differences window helps you choose either the source control version or the database version.

If you use the source control version, the stored procedure is checked out and the text is immediately saved to the database. The process of saving the text to the database (and thus synchronizing with source control) can fail if there have been changes to database objects used by the stored procedure (for example, if a table has been modified by you or another developer). While the stored procedure was in source control, there have been modifications to the database that affect the stored procedure. In this scenario, the checkout from source control will succeed, but the update to the database (including the compilation of the stored procedure) will fail, leaving the previous compiled procedure intact.

This error message can also appear when you use the Undo Check Out command and the database version of the stored procedure is different from the source control version. In this scenario, the Undo Checkout command will succeed but the compilation of the stored procedure on the database may fail if there have been changes to database objects that affect the source control version of the stored procedure.

As a general rule, you should always keep the database and source control versions of stored procedures synchronized.

To correct this error

  1. Using the editor, synchronize the text of the identically named stored procedures in both the database and source control.

    -or-

  2. Use unique names for each different stored procedure. You can copy the database version of a stored procedure and then give it a new name: using Server Explorer, open the stored procedure for editing and then modify the procedure name at the top of the file. After saving the newly named procedure, delete the old stored procedure in Server Explorer. You can rename stored procedures in source control by using the Rename command.