Introduction - How To Setup Linked Servers
If you want to use a database from another Server Instance in your queries, you should do some workaround to reach your goal, or better say if you have distributed databases for an application and you want to use distributed queries here is the simple, easy solution.
Background
Googling around would get you to this solution but it's important to know how much time you would spend on something. On this issue, it was so time consuming to find out how to really config the server to get it working, so now it's not.
Using the Code
This option is also available for SQL Server 2000. You should go to [Security]>[Linked Servers] tab under the connected SQL Server Instance.
I. Setting up Linked Server for Using as a NamedServer
- Connect to the specified DB Instance that you are going to use the Shared Server (Linked Server) in it.
- Go to [Server Objects] and on the [Linked Servers] perform a [Right-Click] and select [New Linked Server...].
- In the new window on [General] page, you have to set several parameters as below:
- [Linked server]: LLSS (The name that will be used for addressing the Shared server)
SELECT * FROM [LLSS].[DBName].[Schema].[TableName]
SELECT * FROM [SERVER134].[CompanyDB].[dbo].[Employee]
- [Server type]: Select [Other data source] Option
- [Provider]: [Choose SQL Native Client]
- [Product Name]: ZZZZZZZZZ (Shouldn't be empty and anything can be set, e.g. Instance Name)
[ZZZZZZZZZ]
[Server2005]
- [Data source]: XXX.XXX.XXX.XXX\DDSS (The Network name of SQL Server that is going to be shared on current Instance).
[ XXX.XXX.XXX.XXX\DDSS]
[192.168.100.134\Server2005]
- [Provider string]: (leave this parameter empty)
- [Location]: is disabled (leave this parameter empty)
- [Catalog]: the database Name (set your default database or leave it empty)
- Go to [Security] page, select [be made using this security context] option and set parameters as below:
- [Remote login]: XX (the shared server login user name)
[XX]
[sa]
- [With Password]: YY (the shared server login password)
[YY]
[MyS@P@ss ]
- Press [OK ] and you are ready to go … and use the Linked Server as mentioned in part 3.1.
II. Setting up Linked Server for Using as a NetworkName
- Connect to specified DB Instance that you are going to use the Shared Server (Linked Server) in it.
- Go to [Server Objects] and on the [Linked Servers] perform a [Right-Click] and select [New Linked Server...].
- In the new window, you have to set several parameters as below:
- [ Linked server] : XXX.XXX.XXX.XXX\DDSS (The NetworkName of Shared Server that will be used for addressing the Shared server).
SELECT * FROM [XXX.XXX.XXX.XXX\DDSS].[DBName].[Schema].[TableName]
SELECT * FROM [192.168.100.134\SERVER2005].[ CompanyDB].[dbo].[Employee]
- [Server type] : Select [SQL Server] Option
- Go to [Security] page, select [be made using this security context] option and set parameters as below:
- [Remote login]: XX (the shared server login user name)
[XX]
[sa]
- [With Password]: YY (the shared server login password)
[YY]
[MyS@P@ss ]
- Press [OK ] and you are ready to go … and use the Linked Server as mentioned in part 3.1.
History
- 29th April, 2009: Initial post