SELECT INTO ステートメント
SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。
SQL クエリを使ったデータのエクスポート
次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。
C#
String connectionString = "OAuthClientID=myClientID;OAuthClientSecret=myClientSecret";
using (XeroWorkflowMaxConnection connection = new XeroWorkflowMaxConnection(connectionString)) {
XeroWorkflowMaxCommand cmd = new XeroWorkflowMaxCommand("SELECT UUID, Name INTO [csv://Clients.txt] FROM [Clients] WHERE Name = 'Bob' ", connection);
int rowsAffected = cmd.ExecuteNonQuery();
}
VB.NET
Dim connectionString As [String] = "OAuthClientID=myClientID;OAuthClientSecret=myClientSecret"
Using connection As New XeroWorkflowMaxConnection(connectionString)
Dim cmd As New XeroWorkflowMaxCommand("SELECT UUID, Name INTO [csv://Clients.txt] FROM [Clients] WHERE Name = 'Bob'", connection)
Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。
C#
String connectionString = "OAuthClientID=myClientID;OAuthClientSecret=myClientSecret";
using (XeroWorkflowMaxConnection connection = new XeroWorkflowMaxConnection(connectionString)) {
XeroWorkflowMaxCommand cmd = new XeroWorkflowMaxCommand("SELECT * INTO [Clients] IN [csv://filename=c:/Clients.csv;delimiter=tab] FROM [Clients] WHERE Name = 'Bob'", connection);
int rowsAffected = cmd.ExecuteNonQuery();
}
VB.NET
Dim connectionString As [String] = "OAuthClientID=myClientID;OAuthClientSecret=myClientSecret"
Using connection As New XeroWorkflowMaxConnection(connectionString)
Dim cmd As New XeroWorkflowMaxCommand("SELECT * INTO [Clients] IN [csv://filename=c:/Clients.csv;delimiter=tab] FROM [Clients] WHERE Name = 'Bob'", connection)
Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using