• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

SQLCMD query adding spaces between charactures

Hi,

I have an SQL file like this:

set heading off;
set linesize 10000;
set pagesize 0;
set trimspool on;
set feedback off;

spool daily.txt;

PROMPT name1,name2,name3
Select             somthing || ',' ||
      somthing_else || ',' ||
      and_another
From               sometable;

spool off;

exit;

It is run from a batch file like this:

pushd "I:\somefolder\Automation"

sqlplus user/pw@server @daily.sql


I:\ is a remote drive on a server

When I run this from one machine, the results are fine.
When tested on another machine t h e  r e s u l t s  h a v e  s p a c e s  b e t w e e n  e a c h  c h a r a c t u r e .

U m m m . . .  ?

How can I fix this?  I want to see the results without the extra spaces, but keep any original spaces.  I assume it has something to do with the local machine settings, not the files, since both PC's use the same files from the server.

Thanks!


0
TelMaco
Asked:
TelMaco
  • 3
1 Solution
 
roshnipatelCommented:
Try adding :
SET TRIMSPOOL ON;
spool daily.txt;

PROMPT name1,name2,name3
Select             somthing || ',' ||
      somthing_else || ',' ||
      and_another
From               sometable;

spool off;
SET TRIMSPOOL OFF;

0
 
TelMacoAuthor Commented:
Still getting the extra space after each characture.  (except the headings - the PROMPT bit is fine)

Ran it again from my other PC, and it works as it should.  Also ran a differnt .BAT file from the problem PC, looks like all queries that connect to that specific table give this weird output, but if I query a differnt table, the output is normal.  

Does this even make sense??   I'm running that same .BAT file (saved to a server) from both PC's.  Output should be identical...  I am so confused.

set heading off;
set linesize 10000;
set pagesize 0;
set trimspool on; **This was already here
set feedback off;

spool daily.txt;

PROMPT name1,name2,name3
Select             somthing || ',' ||
      somthing_else || ',' ||
      and_another
From               sometable;

spool off;
SET TRIMSPOOL OFF; ***I added this

exit;
0
 
TelMacoAuthor Commented:
Just discovered that these PC's have different versions of Oracle.  It works on the PC with 10, and adds the spaces in the one with 8.  I'll test upgrading the version.

The other thing I noticed was that it's only queries that contain table joins that result in the spaces.  If I query one table at a time...no spaces.  

0
 
TelMacoAuthor Commented:
I upgraded both the Oracle version and the SQLplus  on the trouble PC to match what I have on the PC that was working.  

Problem solved.

0
 
DhaestCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now