Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sybase isql - output file contains leading and trailing spaces per each column

Posted on 2010-11-23
4
Medium Priority
?
4,925 Views
Last Modified: 2012-05-10
I am using sybase Adaptive Server Enterprise/15.0.2 and running isql from UNIX (solaris 10) to get data from sybase to use other application.
isql -S <server> -U <ID> -P <password> -i <sql file> -s"|" > $outfile

currently result file always contains too many space per column, and I do not want this happen.
would you advise how I can get rid of these spaces ? I've checked manual for isql but could not find such a option...
0
Comment
Question by:sleepingluke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 27

Expert Comment

by:wilcoxon
ID: 34202772
You can't get rid of it with isql itself.  I would suggest running it through sed (this will remove leading and trailing spaces per line):

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's%^  *%%' -e 's%  *$%%' > $outfile

If you mean the columns themselves have too many spaces, in the output display, then I'm not sure what to suggest as the output from isql will always make columns the widest necessary (usually the width defined in the source table).  You could try using subtring or convert in your sql if you know that the max width will be less than the max defined for the column.
0
 
LVL 27

Expert Comment

by:wilcoxon
ID: 34202777
It may not help in this situation (I can't remember all the options off-hand) but I would suggest installing sqsh for use instead of isql.  sqsh is what isql should have been.
0
 
LVL 27

Accepted Solution

by:
wilcoxon earned 2000 total points
ID: 34202786
Hmm, actually, given the output format of -s "|", this command should work for getting rid of extra spaces per column:

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's%|  *%%' -e 's%  *|%%' > $outfile

You may need to add a backslash before the |s in the sed expressions (I always forget if you need them or not to work properly).
0
 

Author Closing Comment

by:sleepingluke
ID: 34202992
thanks! actually below command worked though I just replaced % to / and all rely to your command, appreciated.

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's/|  */|/g' -e 's/  *|/|/g' > $outfile
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question