Add and Remove Link server in Microsoft Sqlserver

Sometime we need to query to database which are on other server, so for that we need to use Microsoft Sqlserver feature Linkserver.

Add link Server

EXEC sp_addlinkedserver
@server = 'SVT-SRV-SQL',
@srvproduct = 'SQLServer',
@provider = 'SQLNCLI', -- provider is depends on your version of link server that you need to add
@datasrc = 'SVT-SRV-SQL'

Login to link server

exec sp_addlinkedsrvlogin 'SVT-SRV-SQL', 'false', NULL, 'Test', 'Test';

Get the list of link server to check your server is added or not.

exec sp_linkedservers

Check by accessing link server

select * from [Svt-srv-sql].Databasename.dbo.Tablename

Remove Link server

exec sp_dropserver 'SVT-SRV-SQl','droplogins'

For more information please check on LinkServer.

About these ads

One thought on “Add and Remove Link server in Microsoft Sqlserver

  1. This is very interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to seeking more of your magnificent post. Also, I’ve shared
    your web site in my social networks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s