Excel Add-In for Square

Build 21.0.8137

SELECT INTO ステートメント

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

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

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

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

C#

String connectionString = "OAuthClientId=MyApplicationId;OAuthClientSecret=MyApplicationSecret;CallbackURL=http://localhost:33333;LocationId=MyDefaultLocation";

using (SquareConnection connection = new SquareConnection(connectionString)) {
  SquareCommand cmd = new SquareCommand("SELECT Id, DeviceName INTO [csv://Payments.txt] FROM [Payments] WHERE Id = 'Jq74mCczmFXk1tC10GB' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "OAuthClientId=MyApplicationId;OAuthClientSecret=MyApplicationSecret;CallbackURL=http://localhost:33333;LocationId=MyDefaultLocation" 

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

C#

String connectionString = "OAuthClientId=MyApplicationId;OAuthClientSecret=MyApplicationSecret;CallbackURL=http://localhost:33333;LocationId=MyDefaultLocation";

using (SquareConnection connection = new SquareConnection(connectionString)) {
  SquareCommand cmd = new SquareCommand("SELECT * INTO [Payments] IN [csv://filename=c:/Payments.csv;delimiter=tab] FROM [Payments] WHERE Id = 'Jq74mCczmFXk1tC10GB'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "OAuthClientId=MyApplicationId;OAuthClientSecret=MyApplicationSecret;CallbackURL=http://localhost:33333;LocationId=MyDefaultLocation" 

Using connection As New SquareConnection(connectionString)
  Dim cmd As New SquareCommand("SELECT * INTO [Payments] IN [csv://filename=c:/Payments.csv;delimiter=tab] FROM [Payments] WHERE Id = 'Jq74mCczmFXk1tC10GB'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 21.0.8137