Madmarlin
asked on
xp_SendMail.. space padding
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..
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..
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
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
RTRIM doesn' work , an explicit CAST ( as VARCHAR) neither... :-(
Your question in MSSQL:
https://www.experts-exchange.com/questions/20309718/xp-SendMail-Padded-spaces-in-text-file.html
https://www.experts-exchange.com/questions/20309718/xp-SendMail-Padded-spaces-in-text-file.html
ASKER
Concatinating the fields works..
ASKER
Marked for deletion
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
Moderator, my recommended disposition is:
Refund points and save as a 0-pt PAQ.
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Query = "USE DB1 Select RTRIM(LTRIM(Forename)) As Forename, RTRIM(LTRIM(surname)) As Surname, RTRIM(LTRIM(age)) As Age From TABLE1",