Reputation: 89673
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?
Upvotes: 11
Views: 18676
Reputation: 41569
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
Upvotes: 10
Reputation: 2654
You added the Linked Server, see here about using it. Briefly, Linked servers used to obtain the ability to make distributed queries between your and linked servers:
SELECT MyServer.MyDatabase.dbo.Table1.Field1,
LinkedServer.MyDatabase.dbo.Table2.Field2
FROM MyServer.MyDatabase.dbo.Table1
INNER JOIN LinkedServer.MyDatabase.dbo.Table2
ON MyServer.MyDatabase.dbo.Table1.ID=LinkedServer.MyDatabase.dbo.Table2.ID
Upvotes: 1
Reputation: 432361
You now have a linked server called abc
To remove, use sp_dropserver (There is no sp_droplinkedserver). Thus:
EXEC sp_dropserver 'abc', 'droplogins'
Upvotes: 10