General Reference : User's Guide : Command Line Interface Utilities : deu
 
deu
Description
The deu data export utility exports the results of a SQL SELECT statement to a delimited text file.
Note This utility is agnostic to the rendering or use of binary data by any application. When it exports binary data, it writes it in binary format, such as 0x123abc.
Synopsis
deu database selectfile resultsfile [options]
[-c ] [-e fileencoding] [-f fielddelimiter] [-h] [-l logfile] [-n portnumber]
[-s servername] [-o] [-u loginid] [-p password]
Options
 
database
Database against which the SQL statement in selectfile is to be executed. It can be a database name or a server DSN.
selectfile
Text file that contains the SQL statement to run against database. The file is read from the current directory or from a location using a path provided with the file name.
Note: Unicode characters are not supported. If you use Unicode in the SELECT file, deu returns the error message: "Cannot connect to the designated server."
resultsfile
Text file that contains the results of the SQL SELECT command. The file can be overwritten if it exists. By default, the user is prompted to overwrite unless the -o option is used.
-c
Write column names in the first row of output, preceded by a hash character (#). Without this option, the default is no column names.
-d fileencoding
Read the source file in the specified character encoding. Without this option, the default is the current operating system encoding. The code page name is not case sensitive. See Code Pages for Data Source.
-e fileencoding
Write the results file in the specified character encoding. Without this option, the default is Windows-1252. The code page name is not case sensitive. See Code Pages for SELECT Results.
-f fielddelimiter
Field delimiter character for SELECT results. Without this option, the default is a comma.
-h
Show help.
-l logfile
Write log messages to a file as well as standard output. Logfile is the name of the file to which message entries are logged. The file is written to the current directory or to a location using a path provided with the file name.
-n portnumber
TCP port number where the database engine running on servername is listening. Without this option, port 1583 is the default used for the Relational Engine.
-o
Without prompting, overwrite resultsfile if it exists.
-s servername
Name of the server where the database is defined. Without this option, the local machine is the default. You may use an IP address.
-u loginid
Name of a user defined for a database with security enabled.
-p password
Password for the user identified by loginid.
Code Pages for Data Source
The following values represent code pages available to use with the -d option. Without this option, the default is the current operating system encoding. The values are not case sensitive.
ANSI: CP1250, CP1251, CP1252 (Windows default), CP1253, CP1254, CP1255, CP1256, CP1257, CP1258, CP932, CP936, CP949, CP950
OEM: CP720, CP737, CP775, CP850, CP852, CP855, CP857, CP858, CP862, CP866, EUCJP
Unicode: UTF-8, UTF-16LE
Code Pages for SELECT Results
The following values represent code pages available to use with the -e option Without this option, the default is CP1252. The values are not case sensitive.
ANSI: CP1250, CP1251, CP1252 (Windows default), CP1253, CP1254, CP1255, CP1256, CP1257, CP1258, CP932, CP936, CP949, CP950
OEM: CP720, CP737, CP775, CP850, CP852, CP855, CP857, CP858, CP862, CP866, EUCJP
Unicode: UTF-8, UTF-8-BOM, UTF-16BE, UTF-16BE-BOM, UTF-16LE, UTF-16LE-BOM
Other Exported Formats
The following list shows how deu handles the exporting of selected data types:
BIT – 0 or 1
BFLOAT4, REAL – Scientific notation, precision 7
BFLOAT8, DOUBLE, FLOAT – Scientific notation, precision 16
DATETIME, TIMESTAMP – year-month-day hour:minute:second.nanoseconds
DATE – year-month-day
TIME – hour:minute:seconds
UNIQUEIDENTIFIER – GUID (e.g., 11111111-2222-3333-4444-111111111111)
Examples
The following example is included in the -h help on the deu command line:
deu demodata select.sql datafile.dat -c -l log.txt
In this case, the select.sql and datafile.dat files are expected to reside in the current directory. The following example uses a directory called Data on drive D:
C:\>deu demodata D:\Data\select.sql D:\Data\datafile.dat -c -l D:\Data\log.txt
Deu is designed to accept a SELECT statement in selectfile that results in a single record set. A file that includes more than one SELECT statement, separated by semicolons, returns no error, but deu executes only the first SELECT statement.
In selectfile you can combine multiple SELECT statements using UNION, as shown in the following example:
SELECT * FROM Class WHERE max_size >= 100
UNION
SELECT * FROM Class where max_size <= 25
This query results in one record set.