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..
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',
@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
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..
PS this question is also repeated in other topic areas but points will be given for only one answer across all areas..