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 Id, Color INTO [csv://Tags.txt] FROM [Tags] WHERE CustomerId = '1368175'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 Id, Color INTO [csv://Tags.txt;delimiter=tab] FROM [Tags] WHERE CustomerId = '1368175'
C#
String connectionString = "APIKey='YourAPIKey';APISecret='YourAPISecret'"; using (ShipStationConnection connection = new ShipStationConnection(connectionString)) { ShipStationCommand cmd = new ShipStationCommand("SELECT Id, Color INTO [csv://Tags.txt] FROM [Tags] WHERE CustomerId = '1368175' ", connection); int rowsAffected = cmd.ExecuteNonQuery(); }
VB.NET
Dim connectionString As [String] = "APIKey='YourAPIKey';APISecret='YourAPISecret'" Using connection As New ShipStationConnection(connectionString) Dim cmd As New ShipStationCommand("SELECT Id, Color INTO [csv://Tags.txt] FROM [Tags] WHERE CustomerId = '1368175'", connection) Dim rowsAffected As Integer = cmd.ExecuteNonQuery() End UsingYou can specify other file formats in the URI. The following example exports tab-separated values:
C#
String connectionString = "APIKey='YourAPIKey';APISecret='YourAPISecret'"; using (ShipStationConnection connection = new ShipStationConnection(connectionString)) { ShipStationCommand cmd = new ShipStationCommand("SELECT * INTO [Tags] IN [csv://filename=c:/Tags.csv;delimiter=tab] FROM [Tags] WHERE CustomerId = '1368175'", connection); int rowsAffected = cmd.ExecuteNonQuery(); }
VB.NET
Dim connectionString As [String] = "APIKey='YourAPIKey';APISecret='YourAPISecret'" Using connection As New ShipStationConnection(connectionString) Dim cmd As New ShipStationCommand("SELECT * INTO [Tags] IN [csv://filename=c:/Tags.csv;delimiter=tab] FROM [Tags] WHERE CustomerId = '1368175'", connection) Dim rowsAffected As Integer = cmd.ExecuteNonQuery() End Using