Solved

xp_SendMail.. space padding

Posted on 2002-06-10
8
286 Views
Last Modified: 2012-08-13
All,
The following SQL is run in an overnight job, the purpose to run a SQL query and email the results in a text file to a valid email address..



use Master
exec xp_sendmail @recipients = "MADMARLIN@HOME.co.uk",
                    @Message = "Please Find Enclosed The Information Pack Requests",
           @separator  = ",",
           @Query = "USE DB1 Select Forename, surname, age From TABLE1",
              @subject = "TEST ONLY",
           @attach_results = 'TRUE',
           @no_header ='True',
           @width = 1000


The process runs fine but the fields within the text file show as follows

john       ,smith      ,21  ,

Is there anyway I can stop this padding of spaces???
and so the text file would read as
john,smith,21,

The fields are all varchars with different lengths which I think may be part of the problem. The additional spaces dont sem to be stored in the DB field so I'm assuming its looking at the field max length and padding accordingly..

Any ideas??

Madmarlin

PS this question is also repeated in other topic areas but points will be given for only one answer across all areas..
0
Comment
Question by:Madmarlin
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Try          

@Query = "USE DB1 Select RTRIM(LTRIM(Forename)) As Forename, RTRIM(LTRIM(surname)) As Surname, RTRIM(LTRIM(age)) As Age From TABLE1",
 
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
hi,

 it seems that xp_sendmail always uses fixed caracter with for sending the data. I couldn't find any solution for that except using workarounds:
* http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312839
* save the output to file and send the file as attachment...

CHeers
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
RTRIM doesn' work , an explicit CAST ( as VARCHAR) neither... :-(
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:Madmarlin
Comment Utility


Concatinating the fields works..
0
 
LVL 1

Author Comment

by:Madmarlin
Comment Utility
Marked for deletion
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Madmarlin, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now