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