I want to create a Linked Server in MS SQL Server 2000 to a MS SQL 2005 Server which runs on port x (not the default port 1433). But it doesn't work, as I can't specify the port anywhere!?
Using sqlcmd (specifying port x), I can connect to the server without problems - but I can't set it up as a Linked Server.
How can this be done?
By default linked servers also use port 1433. For better answers on performance questions, click on the following...
Follow the steps below to create a linked server from the Object Explorer. Open SQL Server Management Studio and connect to an instance of SQL Server. In the Object Explorer, expand the node for the SQL Server database. In the Server Objects node, right-click Linked Servers and click New Linked Server.
Note that 4-part queries will look similar to this:
SELECT * FROM [SQLSERVER,14333].[DATABASE].[dbo].[Table1]
I had to do this today as well (add a linked server with non-default port). In my case it was adding a SQL Server 2014 linked server to a SQL Server 2016.
Steps using SQL Server Management Studio:
Use this format for the Linked Server
ip-address-of-linked-server\instance-name,non-default-port
or, 192.168.10.5\dev-sql,25250
. Instance name is required only if that instance is not the default instance on target linked server. Also, you can replace ip address by host name if the linked server is on your local network.
Select SQL Server for Server Type
Same thing using T-SQL:
EXEC master.dbo.sp_addlinkedserver @server = N'192.168.10.5\dev-sql,25250', @srvproduct=N'SQL Server'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'192.168.10.5\dev-sql,25250',@useself=N'False',@locallogin=NULL,@rmtuser=N'my_username',@rmtpassword='my_pswd'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With