OpenDataSource Usage

OpenDataSource 使用ad hoc 链接信息链接到Remote Data Source,而不是使用Linked Server,而OpenDataSource Row Set函数的作用是在使用 four-part object name 定位一个object时,提供ServerName\InstanceName。SQL Server 任何一个Object完全指定的命名结构依次是:Server Name,Instance Name,Database name,Schema Name,Object name。

Provides ad hoc connection information as part of a four-part object name without using a linked server name.

Openquery 函数是不确定性的函数,就是说,对于相同的输入值,不保证每次返回的值都是相同的。

All rowset functions are nondeterministic. This means these functions do not always return the same results every time they are called, even with the same set of input values.

Syntax

OPENDATASOURCE ( provider_name, init_string )

Arguments

provider_name                                

Is the name registered as the PROGID of the OLE DB provider used to access the data source. provider_name is a char data type, with no default value.

init_string  

Is the connection string passed to the destination provider. The provider string syntax is based on keyword-value pairs separated by semicolons, such as: keyword1=value; keyword2=value.

For specific keyword-value pairs supported on the provider, see the Microsoft Data Access SDK. This documentation defines the basic syntax. The following table lists the most frequently used keywords in the init_string argument.


Keyword


OLE DB property


Valid values and description


Data Source


DBPROP_INIT_DATASOURCE


Name of the data source to connect to. Different providers interpret this in different ways. For SQL Server Native Client OLE DB provider, this indicates the name of the server. For Jet OLE DB provider, this indicates the full path of the .mdb file or .xls file.


Location


DBPROP_INIT_LOCATION


Location of the database to connect to.


Extended Properties


DBPROP_INIT_PROVIDERSTRING


The provider-specific connect-string.


Connect timeout


DBPROP_INIT_TIMEOUT


Time-out value after which the connection try fails.


User ID


DBPROP_AUTH_USERID


User ID to be used for the connection.


Password


DBPROP_AUTH_PASSWORD


Password to be used for the connection.


Catalog


DBPROP_INIT_CATALOG


The name of the initial or default catalog when connecting to the data source.


Integrated Security


DBPROP_AUTH_INTEGRATED


SSPI, to specify Windows Authentication

Remarks

OPENDATASOURCE can be used to access remote data from OLE DB data sources only when the DisallowAdhocAccess registry option is explicitly set to 0 for the specified provider, and the Ad Hoc Distributed Queries advanced configuration option is enabled. When these options are not set, the default behavior does not allow for ad hoc access.

The OPENDATASOURCE function can be used in the same Transact-SQL syntax locations as a linked-server name. Therefore, OPENDATASOURCE can be used as the first part of a four-part name that refers to a table or view name in a SELECT, INSERT, UPDATE, or DELETE statement, or to a remote stored procedure in an EXECUTE statement. When executing remote stored procedures, OPENDATASOURCE should refer to another instance of SQL Server. OPENDATASOURCE does not accept variables for its arguments.

Like the OPENROWSET function, OPENDATASOURCE should only reference OLE DB data sources that are accessed infrequently. Define a linked server for any data sources accessed more than several times. Neither OPENDATASOURCE nor OPENROWSET provide all the functionality of linked-server definitions, such as security management and the ability to query catalog information. All connection information, including passwords, must be provided every time that OPENDATASOURCE is called.

Example

SELECT *
FROM OPENDATASOURCE(‘SQLNCLI‘,
    ‘Data Source=London\Payroll;Integrated Security=SSPI‘)
    .AdventureWorks2012.HumanResources.Employee

SELECT * FROM OPENDATASOURCE(‘Microsoft.Jet.OLEDB.4.0‘,
‘Data Source=C:\DataFolder\Documents\TestExcel.xls;Extended Properties=EXCEL 5.0‘)...[Sheet1$] ;

引用文档:MSDN OPENDATASOURCE (Transact-SQL)

时间: 2024-10-14 21:48:27

OpenDataSource Usage的相关文章

sharepoint 2013 开启 Usage and Health Data Collection

Usage and Health Data Collection Monitoring the status of your farm's health is a critical aspect of SharePoint administration. This service application collects the various logging information stored in SharePoint and writes it to the logging databa

[转]Disk Space Usage and SQL Server Performance

Disk Space Usage and SQL Server Performance By Gregory A. Larsen When you think of SQL Server performance components, you think of the usage of CPU, memory, and the I/O it takes to process a query. However, there is another component you should consi

CSS减肥的工具–Firefox插件 CSS Usage

首先,我们需要安装Firefox(猛击此处下载),或者确定你已经安装的版本已经高于3.1; 第二步,安装前端开发人员最普及的开发工具 Firebug: 第三步,安装CSS Usage 0.3.4.1: 第四步,在浏览器中打开我们要优化的页面(本地的页面也可以),点击右下角的firebug小图标,打开firebug工具窗口,我们会看到在工具选项中我们有一个 CSS Usage工具的按钮. 首先我们来分析最上面的三个功能按钮的使用 Scan: 通过字面意思我们就能知道,这是一个扫描当前页面的工具,如

【DataStructure】Description and usage of queue

[Description] A queue is a collection that implements the first-in-first-out protocal. This means that the only accessiable object in the collection in the first one that was inserted. The most common example of a queue is a waiting line. [Interface]

【DataStructure】One of queue usage: Simulation System

Statements: This blog was written by me, but most of content  is quoted from book[Data Structure with Java Hubbard] [Description] This simulationillustrates objectoriented programming(OOP). Java objects are instantiated to represent all the interacti

[转]printk usage

原文地址:http://elinux.org/Debugging_by_printing#Usage If variable is of Type, use printk format specifier: --------------------------------------------------------- int %d or %x unsigned int %u or %x long %ld or %lx unsigned long %lu or %lx long long %l

Windows 8 Disk Usage Keep up 100%

Recently i find the windows8 Disk Usage always keep up 100%, It must be have some issue. Step1. Go into Open Task Manager Step2. Go to Details tab Step3. Right click the columns headers and click "Select Columns" Step4. From the "Select Col

Linux tar command usage

Linux tar command usage */--> Linux tar command usage Table of Contents 1. Create an archive: 2. Create a gzipped archive: 3. List the files in an archive 4. Add a file or directory to an existing archive The frequently used tar command are listed as

A Complete Guide to Usage of ‘usermod’ command– 15 Practical Examples with Screenshots

https://www.tecmint.com/usermod-command-examples/ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In Unix/Linux distribut