Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I am trying to select just the value from a table on SQL Anywhere 12.0.1 and keep getting strange characters in the first columns of the output file:

Example command:

dbisql @dbadmin_dbn -nogui "unload select VolumeName from backupvols 
    where BackupScheduleID = ${BKPSET} to '${MASTERLOG}' 
    FORMAT ascii delimited by ' '"

Example output:

$ cat /tmp/nvitpcmnf550_11_25_2013_13.04.16_log
'eac_dv_sybsft1_01'
'eac_dv_sybbkp_01'

How do I get rid of these odd characters ?

asked 25 Nov '13, 14:08

JoStick's gravatar image

JoStick
46113
accept rate: 0%

edited 25 Nov '13, 14:46

Graeme%20Perrow's gravatar image

Graeme Perrow
9.6k379124


From: http://en.wikipedia.org/wiki/Byte_order_mark (BOM)

The UTF-8 representation of the BOM is the byte sequence 0xEF,0xBB,0xBF. A text editor or web browser interpreting the text as ISO-8859-1 or CP1252 will display the characters  for this.

Meaning that your source data is UTF-8, and are displaying it currently using CP1252.

From: http://dcx.sybase.com/index.html#sa160/en/dbreference/unload-statement.html

BYTE ORDER MARK clause - Use this clause to specify whether a byte order mark (BOM) should be written. By default, this option is ON, provided the destination for the unload is a local or client file. When the BYTE ORDER MARK option is ON and the ENCODING is UTF-8 or UTF-16, then a BOM is written. If BYTE ORDER MARK is OFF, a BOM is not unloaded.

So, use BYTE ORDER MARK OFF to not output the byte order mark. However, if you're not using the BOM, you should also be aware of the encoding choice on the output data:

ENCODING clause - All database data is translated from the database character encoding to the specified CHAR or NCHAR encoding. When ENCODING is not specified, the database's CHAR encoding is used.

Specify the BYTE ORDER MARK clause to include a byte order mark in the data.

Your database character encoding is UTF-8, so the default is ENCODING 'UTF-8' to specify that the data is to be output using UTF-8 - you may need to specify an alternate encoding that matches your destination text encoding (e.g. ENCODING 'CP1252').

permanent link

answered 25 Nov '13, 15:37

Jeff%20Albion's gravatar image

Jeff Albion
10.8k171175
accept rate: 25%

edited 25 Nov '13, 15:50

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×68

question asked: 25 Nov '13, 14:08

question was seen: 2,478 times

last updated: 25 Nov '13, 15:50