FireDAC Components for UPS

Build 20.0.7587

SELECT INTO Statements

You can use the SELECT INTO statement to export formatted data to a file.

Data Export with an SQL Query

The following query exports data into a file formatted in comma-separated values (CSV):

SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25'
You can specify other formats in the file URI. The possible delimiters are tab, semicolon, and comma with the default being a comma. The following example exports tab-separated values:
SELECT FirstName, Phone INTO [csv://Senders.txt;delimiter=tab] FROM [Senders] WHERE SenderID = '25'

C#

String connectionString = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';";

using (UPSConnection connection = new UPSConnection(connectionString)) {
  UPSCommand cmd = new UPSCommand("SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';" 

Using connection As New UPSConnection(connectionString)
  Dim cmd As New UPSCommand("SELECT FirstName, Phone INTO [csv://Senders.txt] FROM [Senders] WHERE SenderID = '25'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
You can specify other file formats in the URI. The following example exports tab-separated values:

C#

String connectionString = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';";

using (UPSConnection connection = new UPSConnection(connectionString)) {
  UPSCommand cmd = new UPSCommand("SELECT * INTO [Senders] IN [csv://filename=c:/Senders.csv;delimiter=tab] FROM [Senders] WHERE SenderID = '25'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "Server='https://wwwcie.ups.com/ups.app/xml';AccessKey='346DAC9059AF258';Password='zxczxqqtyiuowkdlkn';AccountNumber='11F0E7A';UserId='alsdkfjpqoewiru';
PrintLabelLocation='C:\users\username\documents\mylabels';CacheLocation='C:\users\username\documents\upscache';" 

Using connection As New UPSConnection(connectionString)
  Dim cmd As New UPSCommand("SELECT * INTO [Senders] IN [csv://filename=c:/Senders.csv;delimiter=tab] FROM [Senders] WHERE SenderID = '25'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

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