Duplicate definition troubleshooting in SQL Source Control Duplicate definition troubleshooting in SQL Source Control

Duplicate definition troubleshooting in SQL Source Control

You get the error "A duplicate definition was found for the table..."

The duplicate error is usually caused by unnecessary files in your repository which have resulted in duplicate CREATE statements for an object. In most cases, the files were added manually to the repository. It's important that the repository that SQL Source Control (SOC) uses doesn't contain anything else apart from files generated by SOC.

mceclip0.png

mceclip8.png

1. Make sure you are on the latest version of SQL Source Control (Help>Check for updates).

2. To find the offending file, you can search your repository for all the CREATE statements for the object referenced in the error. 

First check the Transient folder which is a representation of the source control repository.

Go to Setup > Under The Hood > Open Transient

mceclip2.png

3. If you have Notepad++ you can use the Search > Find in Files option to search the folder for instances of the CREATE string or object name.

mceclip3.png

The search produces results for potentially multiple definitions.

mceclip4.png

Double click on these entries to open the full object and see the DDL.

mceclip5.png

mceclip6.png

4. This example shows two duplicate create statements for what looks like two difference objects. You'll need to delete the duplicate from the repository directly, e.g. this could be your Azure DevOps repo, BitBucket, Github.

5. Unlink and relink the database from SOC to refresh your working copies and transient copies.

If the problem persists please log a ticket with support and attach a zipped copy of the Working Base and Transient Folders of the database where you are experiencing this issue.