CData ODBC Driver for Google Ads 2019J - Online Help

SELECT INTO ステートメント

CData ODBC Driver for Google Ads 2019J - Build 19.0.7354

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

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

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

SELECT Clicks, Device INTO [csv://CampaignPerformance.txt] FROM [CampaignPerformance] WHERE Device = 'Mobile devices with full browsers'
ファイルURI で他のフォーマットを指定できます。利用可能な区切り文字はタブ、セミコロン、カンマです。デフォルトはカンマです。次の例は、tab-separated values(TSV)にエクスポートします。
SELECT Clicks, Device INTO [csv://CampaignPerformance.txt;delimiter=tab] FROM [CampaignPerformance] WHERE Device = 'Mobile devices with full browsers'

C#

String connectionString = "DeveloperToken=myDeveloperToken;ClientCustomerId=myClientCustomerId;";

using (GoogleAdsConnection connection = new GoogleAdsConnection(connectionString)) {
  GoogleAdsCommand cmd = new GoogleAdsCommand("SELECT Clicks, Device INTO [csv://CampaignPerformance.txt] FROM [CampaignPerformance] WHERE Device = 'Mobile devices with full browsers' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "DeveloperToken=myDeveloperToken;ClientCustomerId=myClientCustomerId;" 

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

C#

String connectionString = "DeveloperToken=myDeveloperToken;ClientCustomerId=myClientCustomerId;";

using (GoogleAdsConnection connection = new GoogleAdsConnection(connectionString)) {
  GoogleAdsCommand cmd = new GoogleAdsCommand("SELECT * INTO [CampaignPerformance] IN [csv://filename=c:/CampaignPerformance.csv;delimiter=tab] FROM [CampaignPerformance] WHERE Device = 'Mobile devices with full browsers'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "DeveloperToken=myDeveloperToken;ClientCustomerId=myClientCustomerId;" 

Using connection As New GoogleAdsConnection(connectionString)
  Dim cmd As New GoogleAdsCommand("SELECT * INTO [CampaignPerformance] IN [csv://filename=c:/CampaignPerformance.csv;delimiter=tab] FROM [CampaignPerformance] WHERE Device = 'Mobile devices with full browsers'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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