Excel Add-In for SharePoint

Build 20.0.7695

SELECT INTO ステートメント

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

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

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

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

C#

String connectionString = "User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;";

using (SharePointConnection connection = new SharePointConnection(connectionString)) {
  SharePointCommand cmd = new SharePointCommand("SELECT Id, Location INTO [csv://Calendar.txt] FROM [Calendar] WHERE Location = 'Chapel Hill' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;" 

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

C#

String connectionString = "User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;";

using (SharePointConnection connection = new SharePointConnection(connectionString)) {
  SharePointCommand cmd = new SharePointCommand("SELECT * INTO [Calendar] IN [csv://filename=c:/Calendar.csv;delimiter=tab] FROM [Calendar] WHERE Location <> 'Chapel Hill'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;" 

Using connection As New SharePointConnection(connectionString)
  Dim cmd As New SharePointCommand("SELECT * INTO [Calendar] IN [csv://filename=c:/Calendar.csv;delimiter=tab] FROM [Calendar] WHERE Location <> 'Chapel Hill'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 20.0.7695