SSIS Components for Dynamics 365 Business Central

Build 20.0.7656

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;OrganizationUrl=https://api.businesscentral.dynamics.com/v1.0/api/v1.0";

using (D365BusinessCentralConnection connection = new D365BusinessCentralConnection(connectionString)) {
  D365BusinessCentralCommand cmd = new D365BusinessCentralCommand("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://api.businesscentral.dynamics.com/v1.0/api/v1.0" 

Using connection As New D365BusinessCentralConnection(connectionString)
  Dim cmd As New D365BusinessCentralCommand("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://api.businesscentral.dynamics.com/v1.0/api/v1.0";

using (D365BusinessCentralConnection connection = new D365BusinessCentralConnection(connectionString)) {
  D365BusinessCentralCommand cmd = new D365BusinessCentralCommand("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://api.businesscentral.dynamics.com/v1.0/api/v1.0" 

Using connection As New D365BusinessCentralConnection(connectionString)
  Dim cmd As New D365BusinessCentralCommand("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.7656