Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to undo sp_addlinkedserver abc,'SQL Server'?

Wow i was just playing around with sp_addlinkedserver and i accidentally ran this command: sp_addlinkedserver abc,'SQL Server'

1) i had command(s) completed successfully.. but what happened?

2) how do i undo what i did?

like image 694
Pacerier Avatar asked Aug 15 '11 09:08

Pacerier


People also ask

How do I remove a linked server in SQL?

To remove all remote and linked server logins for a server when you remove the server, use the droplogins argument. sp_dropserver cannot be executed inside a user-defined transaction.

What is Sp_addlinkedserver?

A linked server allows for access to distributed, heterogeneous queries against OLE DB data sources. After a linked server is created by using sp_addlinkedserver , distributed queries can be run against this server. If the linked server is defined as an instance of SQL Server, remote stored procedures can be executed.

How do I find the linked server name SQL Server?

This can be done by clicking on the Server objects under the Server engine tab. As we can see all available SQL Server objects will be listed below the Object type grid.

What is the use of Openquery in SQL Server?

Executes the specified pass-through query on the specified linked server. This server is an OLE DB data source. OPENQUERY can be referenced in the FROM clause of a query as if it were a table name. OPENQUERY can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement.


2 Answers

You created a link to a server named abc.

You could try to query the server across this link using a command such as:

select * 
from abc.master.information_schema.tables

But (unless you really do have a server called abc) it'll return you a message similar to:

OLE DB provider "SQLNCLI10" for linked server "abc" returned message "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.".

You can view your linked server in SSMS under Server Objects>>Linked Servers in the Object Explorer.

To get rid of the linked server, use the following statement:

sp_dropserver abc
like image 164
Jon Egerton Avatar answered Nov 15 '22 22:11

Jon Egerton


You now have a linked server called abc

To remove, use sp_dropserver (There is no sp_droplinkedserver). Thus:

EXEC sp_dropserver 'abc', 'droplogins'
like image 39
gbn Avatar answered Nov 15 '22 23:11

gbn