SSIS Components for Business b-ridge

Build 20.0.7656

SELECT INTO ステートメント

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

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

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

C#

String connectionString = "ConnectionProperty1=Value1;ConnectionProperty2=Value2";

using (BusinessbridgeConnection connection = new BusinessbridgeConnection(connectionString)) {
  BusinessbridgeCommand cmd = new BusinessbridgeCommand("SELECT ItemId, StructureId INTO [csv://CDATA.txt] FROM [CDATA] WHERE ItemTypeId = '1' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "ConnectionProperty1=Value1;ConnectionProperty2=Value2" 

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

C#

String connectionString = "ConnectionProperty1=Value1;ConnectionProperty2=Value2";

using (BusinessbridgeConnection connection = new BusinessbridgeConnection(connectionString)) {
  BusinessbridgeCommand cmd = new BusinessbridgeCommand("SELECT * INTO [CDATA] IN [csv://filename=c:/CDATA.csv;delimiter=tab] FROM [CDATA] WHERE ItemTypeId = '1'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "ConnectionProperty1=Value1;ConnectionProperty2=Value2" 

Using connection As New BusinessbridgeConnection(connectionString)
  Dim cmd As New BusinessbridgeCommand("SELECT * INTO [CDATA] IN [csv://filename=c:/CDATA.csv;delimiter=tab] FROM [CDATA] WHERE ItemTypeId = '1'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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