0

I've created alias for my instance, like it is said here How do we alias a Sql Server instance name used in a Connection String .config? or here http://technet.microsoft.com/en-us/library/ms190445.aspx.

I can connect to it locally using InstanceAliasName.

But I can't connect locally to this alias using MachineName\InstanceAlias. I receive an error:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)"

How can I connect to ServerName\InstanceAlias?

Community
  • 1
  • 1
Alex Blokha
  • 1,141
  • 2
  • 17
  • 30
  • Fix what? That's the way alias works. It's so you can use the same name for more than one instance. Instance being ServerName\InstanceName – Tony Hopkinson Jan 11 '14 at 16:34
  • I didn't understand, can I use ServerName\InstanceAlias? – Alex Blokha Jan 11 '14 at 16:49
  • In a word no. and Alias already has a machine name so if you has alias M1\MyInstance = MInstance, by asking for M1\MInstance it would be looking for M1\M1\MyInstance. – Tony Hopkinson Jan 11 '14 at 17:00
  • No, I don't have machine name in alias. My alias is called SQLEXPRESS2008. And I want to connect as MyMachine\SQLEXPRESS2008 – Alex Blokha Jan 11 '14 at 17:15
  • ??? Alias SomeMachine\SomeInstance as SQLEXPRESS2008 . So SQL server looks in it's list of aliases and translates SQLEXPRESS2008 to SomeMachine\SomeInstance! So if you prefix the alias with machine name it would end up with two machine names in it. – Tony Hopkinson Jan 11 '14 at 17:21
  • 1
    Whole point of an alias is to not have to know which machine the instance is on. It's so you and I could write a piece of software and use a connection String to CommonDB even though I've aliased it MYDBServer\Project1 and you've aliased it to my MYSpareDBServer\Contract359. – Tony Hopkinson Jan 11 '14 at 17:25

1 Answers1

1

You should create Alias just for instance, It means you can connect only by InstanceAliasName, You can not combine again MachineName and AliasName.

If you create alias with MachineName\InstanceAliasName you can connect by MachineName\InstanceAliasName.

For example: Machine Name: DBSERVER Instance Name: SQL2008R2

You can create alias name same as: DBSERVER\SQLS

Now you can connect to instance by DBSERVER\SQLS.

Hadi Sharifi
  • 1,497
  • 5
  • 18
  • 28
  • I've marked it as answer, but I think you should rephrase it. Its hard to understand. My proposition: "The alias name should be in the form "MachineName\NewName". Comments from Tony Hopkinson were also helpful. – Alex Blokha Jan 22 '14 at 15:50
  • @HadiSharifi Just to clarify, you don't need to use MachineName at all. An alias can be any arbitrary name like NewSQLServer and when you connect to it you only use NewSQLServer as the Server Name. The alias is essentially letting you replace "serverName/instname, portNo" with just "aliasName". – Jacques Mar 15 '17 at 04:38