Tuesday, January 4, 2011

Linked Server in SQL Server

A linked server configuration enables SQL Server to execute commands/T-SQL statements against OLE DB data sources on remote servers. You can query heterogeneous databases using linked server.

Advantage of Linked Server
Remote server access
You can execute distributed queries, updates, commands, and transactions on heterogeneous data sources using linked server
The ability to address diverse data sources similarly.


-- Below procedure will create linked server to communicate with access

Sp_addlinkedserver 'Lnk_AccessDB', 'Access', 'Microsoft.Jet.OLEDB.4.0',

'c:\db1.mdb'


-- query the linked server

SELECT *

FROM   lnk_accessdb...tb1


-- Below query will drop the linked server

EXEC Sp_dropserver 'Lnk_AccessDB' 

No comments:

Post a Comment