.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Explain Linked Sever and How Add a Linked server?

Posted By:Sajid P K       Posted Date: October 21, 2010    Points: 50    Category: DataBase    URL: http://www.dotnetspark.com  

Linked servers are a way to link to different OLEDB compatible data sources from within SQL Server. Here I am Explains the Concept with an example. And Also How Add a Linked server?



We Have two SQL sever named ServeA and ServerB. My Employee table is in ServerA and Salary Table in ServerB.


We need get salary details of each employee from ServerA.





Here we have to link the server B from Server A.  Code for linking is given below



EXEC sp_addlinkedserver @server = N'ServerB', @srvproduct=N'SQL Server'


Now it linked, so we can directly refer Server B from Server A as show below.



SELECT *  FROM [ServeA].dbo.Employee e       INNER JOIN [Serveb].dbo.Salry S on E.EmpID = S.EmpID



Similarly we can connect to any OLEDB compatible Database like Oracle, Access, Excel or any other data source that uses an OLE DB provider



You can Use   sp_dropserver  to remove the linked server.



sp_dropserver    ServerB.



Also list all linked server details, you can use following query.



SELECT * FROM sys.syservers - (SQLServer 2005)
SELECT * FROM master..sysservers - (SQLServer 2000)

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend