Connect to Microsoft Dataverse Data as a Linked Server

摘要:
//myorganization.crm.dynamics.com.Tentin(可选):

Use the SQL Gateway and the ODBC Driver to set up a linked server for Microsoft Dataverse data.

You can use the SQL Gateway to configure a TDS (SQL Server) remoting service and set up a linked server for Microsoft Dataverse data. After you have started the service, you can use the UI in SQL Server Management Studio or call stored procedures to create the linked server. You can then work with Microsoft Dataverse data just as you would a linked SQL Server instance.

Connect to Microsoft Dataverse as an ODBC Data Source

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs. 

You can connect without setting any connection properties for your user credentials. Below are the minimum connection properties required to connect. 

  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  • OrganizationUrl: Set this to the organization URL you are connecting to, such as https://myorganization.crm.dynamics.com.
  • Tenant (optional): Set this if you wish to authenticate to a different tenant than your default. This is required to work with an organization not on your default Tenant.

When you connect the Common Data Service OAuth endpoint opens in your default browser. Log in and grant permissions. The OAuth process completes automatically.

Configure the TDS Remoting Service

See the SQL Gateway Overview for a guide to configure a TDS remoting service in the SQL Gateway UI. The TDS remoting service is a daemon process that listens for TDS requests from clients.

Create a Linked Server for Microsoft Dataverse Data

After you have configured and started the daemon, create the linked server and connect. You can use the UI in SQL Server Management Studio or call stored procedures.

Create a Linked Server from the UI

Follow the steps below to create a linked server from the Object Explorer.

  1. Open SQL Server Management Studio and connect to an instance of SQL Server.
  2. In the Object Explorer, expand the node for the SQL Server database. In the Server Objects node, right-click Linked Servers and click New Linked Server. The New Linked Server dialog is displayed.
  3. In the General section, click the Other Data Source option and enter the following information after naming the linked server:
    • Provider: Select the SQL Server Native Client Provider that corresponds to your version of SQL Server. For example, SQL Server Native Client 11.0. 
    • Data Source: Enter the host and port the TDS remoting service is running on, separated by a comma.

      Note that a value of "localhost" in this input refers to the machine where SQL Server is running so be careful when creating a linked server in Management Studio when not running on the same machine as SQL Server.

    • Catalog: Enter the CData system DSN, CData CDS Sys.
    Connect to Microsoft Dataverse Data as a Linked Server第1张
  4. In the Security section, select the option to have the connection "made using this security context" and enter the username and password of a user you created in the Users tab of the SQL Gateway.Connect to Microsoft Dataverse Data as a Linked Server第2张

Create a Linked Server Programmatically

In addition to using the SQL Server Management Studio UI to create a linked server, you can use stored procedures. The following inputs are required:

  • server: The linked server name.
  • provider: Enter "SQLNCLI", for the SQL Server Native Client Provider.
  • datasrc: The host and port the service is running on, separated by a comma.

    Note that a value of "localhost" in the datasrc input refers to the machine where SQL Server is running, so be careful when creating a linked server in Management Studio when not running on the same machine as SQL Server. 

  • catalog: Enter the system DSN configured for the service.
  • srvproduct: Enter the product name of the data source; this can be an arbitrary value, such as "CData SQL Gateway" or an empty string.
Follow the steps below to create the linked server and configure authentication to the SQL Gateway:
  1. Call sp_addlinkedserver to create the linked server:

    EXEC sp_addlinkedserver @server='CDS',
    @provider='SQLNCLI',
    @datasrc='< MachineIPAddress >,1434',
    @catalog='CData CDS Sys',
    @srvproduct='';
    GO
  2. Call the sp_addlinkedsrvlogin stored procedure to allow SQL Server users to connect with the credentials of an authorized user of the service. Note that the credentials you use to connect to the service must specify a user you configured on the Users tab of the SQL Gateway.

    EXEC sp_addlinkedsrvlogin @rmtsrvname='CDS',
    @rmtuser='admin',
    @rmtpassword='test',
    @useself='FALSE',
    @locallogin=NULL;
    GO

Connect from SQL Server Management Studio

SQL Server Management Studio uses the SQL Server Client OLE DB provider, which requires the ODBC driver to be used inprocess. You must enable the "Allow inprocess" option for the SQL Server Native Client Provider in Management Studio to query the linked server from SQL Server Management Studio. To do this, open the properties for the provider you are using under Server Objects -> Linked Servers -> Providers. Check the "Allow inprocess" option and save the changes.

Execute Queries

You can now execute queries to the Microsoft Dataverse linked server from any tool that can connect to SQL Server. Set the table name accordingly:

SELECT * FROM [linked server name].[CData CDS Sys].[CDS].[Accounts]
Connect to Microsoft Dataverse Data as a Linked Server第3张

免责声明:文章转载自《Connect to Microsoft Dataverse Data as a Linked Server》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇eclipse如何使用log4j详解,你get了吗???Java bean 转为xml下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

JavaScript设置右下角悬浮窗

很多时候,我们需要设置一个dom节点到浏览器窗口的右下角。我们需要那个元素可以在窗口Scroll滚动或者变换大小resize的时候都可以保持浮动在那个位置。这个时候,我在网上看了看,发现很多框架什么啊,或者什么实例,看起来都弱爆了,看起来很复杂,但是直觉告诉我这个明显不是个麻烦事情,所以我自己看了看,终于知道了怎么用很少的代码来优雅的实现,下面列举用nat...

【数据泵】EXPDP导出表结构

【数据泵】EXPDP导出表结构(真实案例) BLOG文档结构图         因工作需要现需要把一个生产库下的元数据(表定义,索引定义,函数定义,包定义,存储过程)导出到测试库上,本来以为很简单的,可是做的过程发现很多的问题,现记录如下,希望有同样需要的朋友不要再走弯路了。     导读 各位技术爱好者,看完本文后,你可以掌握如下的...

JavaScript常用方法(转载)

只能是写限定的东西 代码如下:   只能是中文 <input onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9">   只能是英文和数字.屏蔽了输入法 <input onkeydown="if(event....

yii框架中findall方法取数据使用总结,包括select各种条件,where条件,order by条件,limit限制等

在yii框架中可以使用映射类的find方法取出一条数据或者用findall方法取出数条数据来,那么如何按照所需条件来取数据呢,主要用到了CDbCriteria这个类,这个类是yii自带的操作数据库的支持类,可以作为参数传递给find等方法,这里用findall做个例子: 比如我要取出videoinfo表中的'v_id','title','big_class...

torch 深度学习(3)

torch 深度学习(3) 损失函数,模型训练 前面我们已经完成对数据的预处理和模型的构建,那么接下来为了训练模型应该定义模型的损失函数,然后使用BP算法对模型参数进行调整 损失函数 Criterion 加载包 require 'torch' require 'nn' -- 各种损失函数也是 'nn'这个模块里面的 设定命令行参数 if...

bootstrap-table的一些基本使用及表内编辑的实现

最近工作需要接触了bootstrap-table 所以研究了一下,并做了笔记,红色位置要特别注意  前端主要使用了 jquery bootstrap-table  bootstrap-edittable  bootstrap-table-edittable.js   1)首页我们需要先引用css及js文件 <!---bootstrap使用的是3--&...