1

I need some assistance to figure out if its possible to get the output of a sybase sql query in pipe | separated format.

select top 10 * from  mytable 

The data returned is as follows

I am using sybase ASE 15 as my DB to run queries.

name age number 
sam 20 1233456

I need the data in below format

name|age|number
sam|20|123456

Thanks in advance

GMB
  • 216,147
  • 25
  • 84
  • 135
Newbie
  • 11
  • 2

2 Answers2

0

This question is not about the database itself but about the client - isql. For isql you can achieve this result but writing the query like that:

select top 10 
  name || '|' || convert(varchar, age) || '|' || convert(varchar, number) 
from  mytable

Or, like GMB has statet in the comment you can use a client which allows formatting the output. Something other than isql.

Adam Leszczyński
  • 1,079
  • 7
  • 13
0

If you're going to use isql, the best advice is RTFM. It looks like the -s option will do what you want. If it leaves trailing blanks, you can pipe it into sed with something like:

isql -s '|' ... | sed -E 's/ +\|//g'
James K. Lowden
  • 7,574
  • 1
  • 16
  • 31