[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQLCMD query adding spaces between charactures

Posted on 2011-04-21
6
Medium Priority
?
617 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!


0
Comment
Question by:TelMaco
  • 3
5 Comments
 
LVL 2

Expert Comment

by:roshnipatel
ID: 35442658
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
 

Author Comment

by:TelMaco
ID: 35443920
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
 

Author Comment

by:TelMaco
ID: 35462475
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
 

Accepted Solution

by:
TelMaco earned 0 total points
ID: 35486139
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 35865705
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

873 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