Options

"... is not linked to sql source control" error on linked db

avishoavisho Posts: 8
edited February 17, 2014 9:23AM in SQL Compare Previous Versions
Hi,
I'm trying to compare a db HEAD revision to other DB but unfortunately when trying to use SQL Compare command line I get the "... is not linked to sql source control" error.

Command line:
sqlcompare /server1:myserver /db1:my-linked-db /revision1:HEAD /server2:myserver /db2:my-other-linked-db

Error:
SQL Compare: activated, edition: professional, serial number: XXX-XXX-XXX-XXX
SQL Compare Command Line V10.4.8.87
========================================================================================================
Copyright c Red Gate Software Ltd 1999-2013

Unexpected error: The database myserver.my-linked-db is not linked to SQL Source Control
The database myserver.my-linked-db is not linked to SQL Source Control
RedGate.Shared.Utils.InvalidStateException
at RedGate.Shared.Utils.Aver.#j43(String #Wt6, Object[] #ead)
at RedGate.SQLToolsCommandLine.CommandProcessor.#dRzc(Int32 #HXi)
at RedGate.SQLToolsCommandLine.CommandProcessor.#pcmb(Project #zNSb, DataSourceNumber #o9rc)
at RedGate.SQLCompare.CommandLine.CommandProcessor.#pcmb(Project #zNSb, DataSourceNumber #o9rc)
at RedGate.SQLToolsCommandLine.CommandProcessor.#mcmb()
at RedGate.SQLCompare.CommandLine.CommandProcessor.#wOr()
at RedGate.SQLToolsCommandLine.CommandProcessor.#kcmb()
at RedGate.SQLCompare.CommandLine.CommandProcessor.#kcmb()
at RedGate.SQLToolsCommandLine.CommandProcessor.#OUb()
at #i9G.#OsPb.#6sc(String[] #ead)

What am I missing here?!

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    SQL Compare can automatically determine if a database is linked to source control via SQL Source Control®. If it has not been linked that way and you specify a revision number, you will get this message.

    You can tell if the database has been linked using the extended properties below. They may not be there if you did not link the database using SQL Source Control or if you restored an earlier backup from before it was linked to source control.
    SELECT value FROM fn_listextendedproperty('SQLSourceControl Database Revision', NULL,NULL,NULL,NULL,NULL,NULL)
    SELECT value FROM fn_listextendedproperty('SQLSourceControl Scripts Location', NULL,NULL,NULL,NULL,NULL,NULL)
    SELECT value FROM fn_listextendedproperty('SQLSourceControl Migration Scripts Location', NULL,NULL,NULL,NULL,NULL,NULL)
    
  • Options
    Hi Brain,
    The database - IS - linked to source control and I use it daily (commit, get latest etc...).

    I ran the query you gave me and below are the results:
    Reader A: 39342

    Reader B: <?xml version="1.0" encoding="utf-16" standalone="yes"?> <ISOCCompareLocation version="1" type="SvnLocation"> <RepositoryUrl>https://192.168.0.2:8010/svn/Dev/Projects/Server Projects/Database/trunk/Repository/MYDBNAME/</RepositoryUrl> </ISOCCompareLocation>

    Reader C: <?xml version="1.0" encoding="utf-16" standalone="yes"?> <ISOCCompareLocation version="1" type="SvnLocation"> <RepositoryUrl>https://192.168.0.2:8010/svn/Dev/Projects/Server Projects/Database/trunk/MigrationScripts/MYDBNAME/</RepositoryUrl> </ISOCCompareLocation>

    Please advise,
    Avi
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Is SQL Source Control installed on the same computer, and has the database been linked from that computer so that there is a LinkedDatabases.xml file that mentions that database?
  • Options
    Yes and yes.
    below is the xml part:
    &lt;value version="7" type="LinkedDatabase"&gt;
      &lt;DatabaseId version="2" type="DatabaseId"&gt;
        &lt;ServerAndInstanceName&gt;MY_SERVER\DEV&lt;/ServerAndInstanceName&gt;
        &lt;DatabaseName&gt;MY_DB_NAME&lt;/DatabaseName&gt;
      &lt;/DatabaseId&gt;
      &lt;ISrcCLocation version="1" type="SvnLocation"&gt;
        &lt;RepositoryUrl&gt;https://MY_SVN_SERVER_URL/svn/Dev/Projects/Server Projects/Database/trunk/Repository/MY_DB_NAME/&lt;/RepositoryUrl&gt;
      &lt;/ISrcCLocation&gt;
      &lt;IWorkspaceId version="1" type="WorkspaceId"&gt;
        &lt;RootPath&gt;C:\Users\MY_USERNAME\AppData\Local\Red Gate\SQL Source Control 3\WorkingBases\ihltpb0r.0vn&lt;/RootPath&gt;
      &lt;/IWorkspaceId&gt;
      &lt;LinkedMigrationsLocation version="2" type="LinkedMigrationsLocation"&gt;
        &lt;ISrcCLocation version="1" type="SvnLocation"&gt;
          &lt;RepositoryUrl&gt;https://MY_SVN_SERVER_URL/svn/Dev/Projects/Server Projects/Database/trunk/MigrationScripts/MY_DB_NAME/&lt;/RepositoryUrl&gt;
        &lt;/ISrcCLocation&gt;
        &lt;IWorkspaceId version="1" type="WorkspaceId"&gt;
          &lt;RootPath&gt;C:\Users\MY_USERNAME\AppData\Local\Red Gate\SQL Source Control 3\MigrationsFolderWorkingBases\hzucevn4.rvn&lt;/RootPath&gt;
        &lt;/IWorkspaceId&gt;
        &lt;ITransientWorkspaceId version="1" type="WorkspaceId"&gt;
          &lt;RootPath&gt;C:\Users\MY_USERNAME\AppData\Local\Red Gate\SQL Source Control 3\Transients\nrtgunoo.hvj&lt;/RootPath&gt;
        &lt;/ITransientWorkspaceId&gt;
      &lt;/LinkedMigrationsLocation&gt;
      &lt;SharedModel&gt;False&lt;/SharedModel&gt;
      &lt;ScriptTransientId version="1" type="WorkspaceId"&gt;
        &lt;RootPath&gt;C:\Users\MY_USERNAME\AppData\Local\Red Gate\SQL Source Control 3\Transients\hg2wmwnz.pte&lt;/RootPath&gt;
      &lt;/ScriptTransientId&gt;
    &lt;/value&gt;
    
  • Options
    Are you running the command-line under the same user account as SQL Source Control was used with? Because the LinkedDatabase.xml is in your user profile, running the commandline as a different account may result in this error as it's not able to find that file.


    The other option would be to save the two extended property xml fragments out to two files (call them db.xml and mig.xml). Then add to your command-line the switches:

    /sourcecontrol1 /scriptsfolderxml:<path to db.xml> /migrationsfolder:<path to mig.xml>

    and remove the /server1 and /database1 switches
    Systems Software Engineer

    Redgate Software

  • Options
    yes, it's the same user.

    what's the difference between literally writing in command line and using xml files?
  • Options
    It'll just get processed internally by the engine a different way. The xml files are a slightly 'older' method, originally introduced in early version 10 releases of Compare.
    Systems Software Engineer

    Redgate Software

  • Options
    I created the .xml file but the same error still happens...
  • Options
    I've replied directly to you to get some more information.
    Systems Software Engineer

    Redgate Software

Sign In or Register to comment.