Blog Pages

Linked server

-- get exists linked servers:
select * from sys.servers

-- add new linked server:
exec sp_addlinkedserver 
@server='Dev2008ItaiTest', -- the name of the linked server
@srvproduct= '', -- the product name of the OLE DB data source
@provider='SQLNCLI', -- the unique programmatic identifier (PROGID) of the OLE DB provider that corresponds to this data source
@datasrc='DEV2008', -- server name
@location='', -- the location of the database as interpreted by the OLE DB provider
@provstr='Query Timeout=10' -- another parameters.

Notes:
  • If the product name of the linked server is SQL Server, provider_name, data_source, location, provider_string, and catalog do not have to be specified.
  • Return Values: 0 for success or 1 for failure.

-- use linked server:
select * from Dev2008ItaiTest.DBName.dbo.ObjectName

-- delete linked server:
sp_dropserver @server='Dev2008ItaiTest'

No comments:

Post a Comment