ADO.NET Provider for FreshDesk

Build 20.0.7587

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "Domain=MyDomain;APIKey=myAPIKey;";

using (FreshDeskConnection connection = new FreshDeskConnection(connectionString)) {
  FreshDeskCommand cmd = new FreshDeskCommand("SELECT Id, Name INTO [csv://Tickets.txt] FROM [Tickets] WHERE Status = '2' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "Domain=MyDomain;APIKey=myAPIKey;" 

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

C#

String connectionString = "Domain=MyDomain;APIKey=myAPIKey;";

using (FreshDeskConnection connection = new FreshDeskConnection(connectionString)) {
  FreshDeskCommand cmd = new FreshDeskCommand("SELECT * INTO [Tickets] IN [csv://filename=c:/Tickets.csv;delimiter=tab] FROM [Tickets] WHERE Status = '2'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "Domain=MyDomain;APIKey=myAPIKey;" 

Using connection As New FreshDeskConnection(connectionString)
  Dim cmd As New FreshDeskCommand("SELECT * INTO [Tickets] IN [csv://filename=c:/Tickets.csv;delimiter=tab] FROM [Tickets] WHERE Status = '2'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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