"A duplicate definition was found for the stored procedure '[dbo].[sproc_name]'.

What can I do about this Redgate error received when I try to link a database to source control? "A duplicate definition was found for the stored procedure '[dbo].[sproc_name]'.

Best Answers

  • stonestone Posts: 10 New member
    The repository included several databases, and in SSMS when linking a specific database to source control I was only choosing the repository folder and not the database folder under the repository folder.  My bad.
  • stonestone Posts: 10 New member
    @David Atkinson
    The source code repository included several databases, and in SSMS when linking a specific database to source control I was only choosing the repository folder and not the database folder under the repository folder.  My bad.  Once I chose the database folder under the repository folder everything worked!  Thanks for responding!!

Answers

  • stonestone Posts: 10 New member
    Note:  The same stored procedure '[dbo].[sproc_name]' is in EVERY database on the server instance.
  • stonestone Posts: 10 New member
    Note:  Here is the remaining sentences in the error message:    
    Ensure that case sensitivity options are set correctly and all object creation scripts are valid.If the problem persists, contact Redgate support.
       at RedGate.SQLCompare.Engine.DatabaseObjectExistsException.ThrowIfDuplicateObject[T](String key, Dictionary`2 existingObjects, T dbObject, Func`2 getObjectNameForException)
       at RedGate.SQLCompare.Engine.SerializableDatabaseObjectCollection`1.Add(T value)
       at RedGate.SQLCompare.Engine.StoredProcedures.Add(StoredProcedure value)
       at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.ProcessNodeCreateOrAlterProcedure(Element currentNode)
       at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.TraverseNode(AST node)
       at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.TraverseNode(AST node)
       at RedGate.SQLCompare.Engine.ReadFromFolder.ReadScriptAnalysis.VisitNode(Element node, AnalysisProvider`1 provider)
       at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.AnalyseNode(Element root)
       at RedGate.SQLCompare.Rewriter.Analysis.Analyser`1.Analyse(IEnumerable`1 elements)
       at RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromParseResultPopulator.AddToModel(FileInfo file, ParseResult parseResult, ReadScriptAnalysis analysis, LazyFileContents fullFileText, Boolean throwOnFileParseFailed, List`1 parserMessages)
       at RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromParseResultPopulator.Populate(ParseResult parseResult)
       at RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromScriptFilesPopulator.AddFromFiles(List`1 sortedFiles)
       at RedGate.SQLCompare.Engine.ReadFromFolder.DatabaseFromScriptFilesPopulator.Populate(IEnumerable`1 filesToUse)
       at RedGate.SQLCompare.Engine.Model.DatabaseObjects.DatabaseFromFolderPopulator.DatabaseFromFolderPopulator.PopulateFromFolder(Database database, DirectoryInfo path, ScriptDatabaseInformation dbinfo, Options options, IEnumerable`1 filesToUse, IReadFromFolderCache cache, CancellationToken cancellationToken)
       at RedGate.SQLCompare.Engine.Model.DatabaseObjects.DatabaseFromFolderPopulator.DatabaseFromFolderPopulator.Populate(String path, CancellationToken cancellationToken)
       at RedGate.SQLSourceControl.Engine.CompareEngineImpl.Registration.Incremental.ScriptsFolder.DatabaseFromSnapshotCachePopulator.Populate(String path, CancellationToken cancellationToken)
       at RedGate.SQLCompare.Engine.Database.<>c__DisplayClass126_0.<Register>b__0()
       at RedGate.SQLCompare.Engine.Utils.GetTimeToRun[T](Func`1 action)
       at RedGate.SQLCompare.Engine.Database.Register(String path, ScriptDatabaseInformation dbinfo, Nullable`1 optionsParam, IEnumerable`1 filesToUse, IReadFromFolderCache cache, IDatabaseFromFolderPopulator databasePopulator)
       at RedGate.SQLSourceControl.Engine.CompareEngineImpl.Compare.CompareDatabase.RegisterScriptsFolder(DirectoryInfo path, ICompareScriptDatabaseInformation scriptFolderOptions, ICompareOptions options)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.<>c__DisplayClass4_0.<Register>b__0()
       at RedGate.SQLSourceControl.Engine.Utils.Task.SharedUtilsUtils.DoActionWithCancel(ICancellableOperationStatus status, ICancellable cancellable, Action action)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.CompareDatabaseRegistrar.Register(ScriptsFolderDatabaseSource source, ICancellableOperationStatus status)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.SocDatabaseRegistrar.Register(ScriptsFolderDatabaseSource databaseSource, ICancellableOperationStatus status)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.TwoWorkspaceRegistrar.<>c__DisplayClass14_0.<GetRegisterWorkspacesActions>b__0(ICancellableOperationStatus s)
       at RedGate.SQLSourceControl.Engine.Utils.Task.NamedOperation.Operation(ICancellableOperationStatus cancellableOperation)
       at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.<>c__DisplayClass3_0.<StartTask>b__0()
       at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.ExceptionHandler.ThrowIfErrored()
       at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableUtils.DoInParallel(ICancellableOperationStatus status, INamedOperation[] namedActions)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.TwoWorkspaceRegistrar.RegisterWorkspaces(IWorkspaces workspaces, ICompareScriptDatabaseInformation scriptDatabaseInformation)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.ThreeWayDiffSession.RegisterWorkspaces(IWorkspaces workspaces, SourceControlRevision transientRevision)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.ThreeWayDiffSession.BuildCommon()
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.DiffBuilder.GetChangeSetResolvingNoOps[T](String source, IBoundDatabase boundDatabase, IChangeSetFactory`1 changeSetFactory, ICancellableOperationStatus status, SourceControlOperation sourceControlOperation)
       at RedGate.SQLSourceControl.Engine.Diff.DiffBuildSessions.DiffBuilder.BuildToCommitChangeSet(IBoundDatabase boundDatabase, ICancellableOperationStatus status)
       at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.<GetCancellableCommitableChanges>b__24_0(ICancellableOperationStatus status)
       at RedGate.SQLSourceControl.Engine.Utils.Task.MutexedCancellableOperation`1.<>c__DisplayClass7_0.<Invoke>b__0()
       at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableOperationBase.PerformAction(Action action)
       at RedGate.SQLSourceControl.Engine.Utils.Task.CancellableOperationBase.InvokeWithTracker(Action action)
       at RedGate.SQLSourceControl.Engine.Utils.Task.MutexedCancellableOperation`1.Invoke()
       at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.RunCommitableChangesOperationThenCleanUp(ICancellableOperation`1 changes)
       at RedGate.SQLSourceControl.Engine.Diff.BoundDatabase.<>c__DisplayClass40_0.<NotifyInteractedWith>b__1()
       at RedGate.SQLSourceControl.Engine.Utils.ErrorReporting.ErrorReporterBase.Do(Action toDo, Predicate`1 isFatalPredicate, Boolean rethrow)

  • stonestone Posts: 10 New member
    Note 3:  I tried deleting the stored procedure '[dbo].[sproc_name]'.from the database I was trying to link source code to, but got the same error for the same sproc.
  • Have you searched through the scripts folder files and checked that this procedure isn't referenced twice?
    David Atkinson
    Product Manager
    Redgate Software
Sign In or Register to comment.