Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-11-29 : 21:14:47
|
Greg writes "I am trying to make a comma-delimited list of character values from our database and send them to a client. And I'm seeing some strange behavior from xp_sendmail when I call it from within a sproc.
Using the following params:
Declare @subject varchar(40) Declare @emailfail int Declare @email varchar(40) Declare @ccEmail varchar(40) Declare @attachments varchar(50) Declare @messagebody varchar(400) Declare @QueryString varchar(2000) Declare @emailfail int
Set @email = 'grege@web3000.com'
Select @subject = 'Subject' , @attachments = @subject + '.txt' , @MessageBody = 'List of varchar values' , @email = 'grehrig@yahoo.com' , @Querystring = 'Select top 10 ltrim(rtrim(chrValue1)) from Table'
Exec @emailfail = master..xp_sendmail @recipients = @email , @copy_recipients = @ccemail , @subject = @subject , @message = @MessageBody , @query = @QueryString , @attach_results = 'true' , @attachments = @attachments , @separator = ',' , @no_header = 'true' , @width = 80 -- the default The results I see in the attached text file look like this: charvalue1 ..(about 50 blank spaces).. , charvalue2 .... ,
etc.
Using the @width param on xp_sendmail seems to make it go away, if you use large numbers like 100, but then you have
charval1 ..(one hundred spaces minus len(charval1))..., Charval2 .... , Charval3 .... , etc.
Ideally, I would like to have the text file I send look like a standard CSV format:
charval1, charval2, charval3
Any ideas on how to proceed?" |
|
|
|
|
|
|
|