We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

SQLCMD query adding spaces between charactures

TelMaco
TelMaco asked
on
Medium Priority
649 Views
Last Modified: 2012-05-11
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!


Comment
Watch Question

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;

Author

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;

Author

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.  

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.