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?
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.
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.
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.
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.
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
You now have a linked server called abc
To remove, use sp_dropserver (There is no sp_droplinkedserver). Thus:
EXEC sp_dropserver 'abc', 'droplogins'
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