Accessing Oracle during SQL Server Stored Procedures

Source: Internet
Author: User

1. sp_addmediaserver create a linked server (http://msdn.microsoft.com/zh-cn/library/ms190479.aspx)

Exec sp_addmediaserver
@ Server = 'servername' -- or server IP,
@ Srvproduct = 'oracle ',
@ Provider = 'msdaora ',
@ Datasrc = 'oracledbname ',
@ Location = NULL,
@ Provstr = NULL,
@ Catalog = NULL
 

 

[ @ Server =] ' Server '

The name of the linked server to be created.ServerThe data type of isSysname, No default value.

[ @ Srvproduct =] ' Product_name '

The product name of the ole db data source to be added as the linked server.Product_nameThe data type of isNvarchar (128)The default value is null. IfSQL Server, You do not have to specifyProvider_name,Data_source,Location,Provider_stringAndCatalog.

[ @ Provider =] ' Provider_name '

The unique programming identifier (progid) of the ole db access interface corresponding to this data source ). For the specified ole db access interface installed on the current computer,Provider_nameMust be unique.Provider_nameThe data type of isNvarchar (128)The default value is null.Provider_nameSqlncli is used. Sqlncli is the SQL local OLE DB access interface. The ole db access interface should be registered in the Registry with the specified progid.

[ @ Datasrc =] ' Data_source '

Name of the data source interpreted by the ole db access interface.Data_sourceThe data type of isNvarchar (4000).Data_sourcePassed as the dbprop_init_datasource attribute to initialize the ole db access interface.

[ @ Location =] ' Location '

The location of the database explained by the ole db access interface.LocationThe data type of isNvarchar (4000)The default value is null.LocationPassed as the dbprop_init_location attribute to initialize the ole db access interface.

[ @ Provstr =] ' Provider_string '

The connection string specified by the ole db access interface. It can identify a unique data source.Provider_stringThe data type of isNvarchar (4000)The default value is null.ProvstrOr passIdatainitializeOr set it to the dbprop_init_providerstring attribute to initialize the ole db access interface.

When creating a linked server for the ole db access interface of the SQL local client, you can use the server keyword as server =Servername/InstanceNameTo specify the specific SQL ServerServernameThe instance is the name of the computer that runs SQL Server,InstanceNameIs the name of the specific SQL server instance that the user will connect.

2. sp_add1_srvlogin

Exec sp_addmediasrvlogin @ rmtsrvname = ''servername'' -- or '192. 168.1.100 ',
@ Useself = false,
@ Locallogin = NULL,
@ Rmtuser = 'oracle _ username,
@ Rmtpassword = oracle_userpassword'

 

3. Select * From openquery (@ servername, ''Select ...)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.