Creating a Linked Server and Database Alias

怎甘沉沦 提交于 2019-12-05 08:08:44
Julle

This works. Tested on a SQL2012

http://alexpinsker.blogspot.se/2007/08/how-to-give-alias-to-sql-linked-server.html

There are no problems to add SQL linked server to the specific host running it. But what if you need to give it an alias, rather than use hostname as linked server name? Here is how to do it:

1) Step 1:
• In SQL Server Management Studio open Linked Servers and then 'New Linked Server'.
• Inside of appeared wizard – Select the General tab.
• Specify alias name in "Linked server" field.
• Select SQL Native Client as provider.
• Add sql_server in "Product Name" field (that's the magic).
• In "Data Source" – specify name of the host to be used as linked server.

2) Step 2:
• In Security tab – specify proper security options (e.g. security context)

3) Step 3:
• In Server Options tab – put "Data Access", RPC, "Rpc Out" and "Use Remote Collaboration" to be true.

4) Step 4:
• Enjoy.

If you don't want to specify the database name when querying a table you can create synonym for it.

CREATE SYNONYM [dbo].[DimProduct]
FOR
[AdventureWorksDW].[dbo].[DimProduct]

this will create DimProduct in your Synonyms folder

I'm afraid it's not possible, you'll always have to refer to Server1 explicitly. But if your application is a on server and not on many clients, so there is a limited number of usage points, you can modify the connection string there, so the app would refer to server1 instead of server2 temporarily.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!