SSIS Components for Dynamics 365 Sales

Build 20.0.7587

SELECT INTO ステートメント

SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。

SQL クエリを使ったデータのエクスポート

次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;OrganizationUrl=https://myaccount.crm.dynamics.com/;";

using (D365SalesConnection connection = new D365SalesConnection(connectionString)) {
  D365SalesCommand cmd = new D365SalesCommand("SELECT accountid, Name INTO [csv://Accounts.txt] FROM [Accounts] WHERE Name = 'MyAccount' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;OrganizationUrl=https://myaccount.crm.dynamics.com/;" 

Using connection As New D365SalesConnection(connectionString)
  Dim cmd As New D365SalesCommand("SELECT accountid, Name INTO [csv://Accounts.txt] FROM [Accounts] WHERE Name = 'MyAccount'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;OrganizationUrl=https://myaccount.crm.dynamics.com/;";

using (D365SalesConnection connection = new D365SalesConnection(connectionString)) {
  D365SalesCommand cmd = new D365SalesCommand("SELECT * INTO [Accounts] IN [csv://filename=c:/Accounts.csv;delimiter=tab] FROM [Accounts] WHERE Name <> 'MyAccount'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;OrganizationUrl=https://myaccount.crm.dynamics.com/;" 

Using connection As New D365SalesConnection(connectionString)
  Dim cmd As New D365SalesCommand("SELECT * INTO [Accounts] IN [csv://filename=c:/Accounts.csv;delimiter=tab] FROM [Accounts] WHERE Name <> 'MyAccount'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587