Link to home
Start Free TrialLog in
Avatar of TelMaco
TelMaco

asked on

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!


Avatar of roshnipatel
roshnipatel

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;

Avatar of TelMaco

ASKER

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;
Avatar of TelMaco

ASKER

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.  

ASKER CERTIFIED SOLUTION
Avatar of TelMaco
TelMaco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dirk Haest
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.