Use Microsoft System Stored Procedures

You can use the sp_addlinkedserver system stored procedure from Microsoft SQL Server to programmatically configure a linked server definition. However, using this system stored procedure alone does not provide a way to set the Allow In Process and Level Zero Only options.

To use sp_addlinkedserver you must first configure a linked server and options using the Enterprise Manager , as described in Configuring the Historian OLE DB Provider as a Linked Server. Then, since the options Allow In Process and Level Zero Only apply to all linked servers that use the provider, you can create additional linked server definitions to other Historian servers using sp_addlinkedserver.

Once you create your linked server definitions, you can then perform tasks such as using sp_linkedservers to browse the set of linked servers, or using sp_dropserver to remove a linked server.

Example 1: Configure a Linked Server Definition by Using sp_addlinkedserver

EXEC sp_addlinkedserver @server='MYSERVER_LS', @srvproduct='', @provider='iHOLEDB.iHistorian.1', @datasrc='MY_SERVER'

Example 2: Browse Linked Server Definitions by Using sp_linkedservers

EXEC sp_linkedservers

Example 3: Delete Linked Server Definitions by Using sp_dropserver

EXEC sp_dropserver 'MYSERVER_LS', 'droplogins'

Refer to the Microsoft SQL Server documentation for additional information on sp_addlinkedserver, sp_linkedservers, and sp_dropserver. If you have access to MSDN, refer to the System Stored Procedures topic in the Microsoft SQL Server online documentation.