SQL Schema Comparison Error "Target is unavailable"

Sql ServerVisual Studio-2015Visual Studio-2017

Sql Server Problem Overview


When comparing an SQLServer project in Visual Studio 2015 Update 2 against a database SQL Server 2012, it shows the error "Target is unavailable" or "Source is unavailable" when change the direction.

It used to work properly a couple of months ago. Is there any workaround? I couldn't find any.

Sql Server Solutions


Solution 1 - Sql Server

I have found that using username@servername as the username for connecting will fix the issue when it happens against Azure databases. I've had connections that have historically worked without doing this suddenly stop and then this has fixed it for me.

For instance, when using a login of mylogin and connecting to myserver.database.windows.net, if I instead use [email protected] as the username I won't get the "Source is unavailable" issue.

Solution 2 - Sql Server

I get this error in Visual Studio 2017 when I use SQL Server Authentication but don't save the password. I've tested these steps with Visual Studio 15.6.3 and SQL Server 12.0.5000.0

Fixing the error

This fixes the problem, but the problem comes back the next time I restart Visual Studio.

  1. Go to Tools -> SQL Server -> New Schema Comparison...
  2. Select either Select Source or Select Target
  3. Select Select Connection
  4. Under Recent Connections, find all connections that gave you this error
  5. For each of these, right-click the connection and select Remove from History
  6. Restart Visual Studio
Preventing the error from coming back
  1. Complete Fixing the error above
  2. When you are setting the connection details, check the Remember Password checkbox.
Reproducing the error

If you want to troubleshoot this error, here is how I managed to reproduce it.

  1. Go to Tools -> SQL Server -> New Schema Comparison...
  2. Select a source and target connection
  3. For at least one connection, use SQL Server Authentication but don't select Remember Password
  4. Press Compare
  5. Ensure it works without errors
  6. Restart Visual Studio
  7. Repeat steps 1-4, using the exact same connection details

Solution 3 - Sql Server

After trying everything here, this is what worked for me:

  1. Close VS instance.

  2. Delete the saved connection keys in

> HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\ConnectionMruList

  1. Reopen VS and try again.

Solution 4 - Sql Server

The other answers did not work for me as I was using SQL Server directly and not Azure but after checking the advanced properties of the connection string, I saw that the Authentication was set to "Not Specified" and Network Library was empty.

I changed them and it worked again. Rather strange as it let me select the database for the connection. It just would not let me compare schemas giving the mentioned "Source is unavailable" message.

Sql

Solution 5 - Sql Server

For me it was the \ symbol at the end of the server's ip address in the server name field that fixed it. Very strange.

e.g. instead of 10.10.10.10 i write 10.10.10.10\ and it connects ok.

Note: I'm using Visual Studio 2017.

Solution 6 - Sql Server

I have had mixed results with the other answers here. I was using a save compare file that another developer had put together. This is a standalone SQL Server and not an azure database. The compare would work sometimes and not others (giving the target is unavailable error). In my case the saved compare was just using the server name and not using a FQDN. When I changed to a FQDN it worked for me. I am not sure if the problem will come back again but thought I would add this information in case it is useful for others.

Solution 7 - Sql Server

Although some solutions on this page worked for me sometimes, but not all the times. But this method that I am describing, is working for me most of the times

When you specify your server name specify the protocol and port as this

Servername: tcp:my-server-name,1443

My server name is Azure BTW

Solution 8 - Sql Server

I had this error when opening a previously saved .scmp file which worked successfully when it was initially created.

The problem was caused by missing password in the saved connection string. The source used integrated authentication, so VS was not complaining about that.

Selecting the target connection again did not help, probably because VS used the cached connection string.

I solved the issue by adding the Password argument into the connection string in the file. There are two locations where the target connection string is specified (XPaths shown below):

  • /SchemaComparison/TargetModelProvider/ConnectionBasedModelProvider/ConnectionString
  • /SchemaComparison/SchemaCompareSettingsService/ConfigurationOptionsElement/PropertyElementName[Name='TargetConnectionString']

After these edits I reopened the .scmp file and the comparison ran successfully.

Solution 9 - Sql Server

I have tried in 2015 Visual Studio Professional version and I got this issue at the time of SQL data comparison and it worked for me when I use host name instead of IP address of databases. Hope this will address the issue.

Solution 10 - Sql Server

A process was blocking the database. After executing a kill [spid] it worked again.

Solution 11 - Sql Server

Same problem appears when user have no required permissions to perform schema comparison operation https://msdn.microsoft.com/en-us/library/jj889462(v=vs.103).aspx

Solution 12 - Sql Server

I was referring to SQL server via IP and gave me this problem. I referred to it via its DNS name and problem was solved!

Not sure why! However, it worked like this :)

Solution 13 - Sql Server

I can get it to work when I right click on the database name in the SQL Server Object Explorer window and select Schema Compare from there. If I try to use the Schema Compare window that opens from the Tools menu, it never works.

Solution 14 - Sql Server

I actually had the same problem in VS studio 2015. But as the database was on my PC I was using localhost instead of the actual name of the computer. I just manaully selected the computer server as in the proposition of visual studio itself and it worked.

Solution 15 - Sql Server

None of the answers supplied here worked for me; I am using SQL Server and Visual Studio 2017. I was able to force a comparison by adding the server's IP address to my hosts file, then using that host name in the connection box.

Solution 16 - Sql Server

In my case, I just restarted my machine, and it worked fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondaveView Question on Stackoverflow
Solution 1 - Sql ServerStacy VicknairView Answer on Stackoverflow
Solution 2 - Sql ServerSamView Answer on Stackoverflow
Solution 3 - Sql ServersotnView Answer on Stackoverflow
Solution 4 - Sql ServerKuffsView Answer on Stackoverflow
Solution 5 - Sql ServerknrView Answer on Stackoverflow
Solution 6 - Sql ServerMikeView Answer on Stackoverflow
Solution 7 - Sql ServerGhassan KarwchanView Answer on Stackoverflow
Solution 8 - Sql ServerDark DaskinView Answer on Stackoverflow
Solution 9 - Sql ServerPrabhas Kumar MishraView Answer on Stackoverflow
Solution 10 - Sql ServerdaveView Answer on Stackoverflow
Solution 11 - Sql ServerAdvanTiSSView Answer on Stackoverflow
Solution 12 - Sql ServerEvan CamilleriView Answer on Stackoverflow
Solution 13 - Sql Serveruser9791281View Answer on Stackoverflow
Solution 14 - Sql ServeresdrasView Answer on Stackoverflow
Solution 15 - Sql ServerpixelbathView Answer on Stackoverflow
Solution 16 - Sql ServerYamanView Answer on Stackoverflow