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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 use xp_sendmail to attach csv file

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-02 : 07:26:48
th34 writes "I am using xp_sendmail to attach a csv file in my email. This work fine except in the zip code field. If there is a leading zero in the zip code field, the leading zero will be dropped when view in excel. I need to open the file in excel. I know it works if I export the file as text file. any suggestions???

execute master..xp_sendmail
@recipients = 'test.com',
@Subject = 'NorthWind',
@message = '',
@query = 'select lastname, firstname, postalcode from employees',
@attach_results = 'true',
@width = 800,
@no_header = 'false',
@separator = ',',
@attachments = 'employees.csv',
@dbuse = 'NorthWind'"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-07-02 : 07:28:53
You'd have to change your query a little:

SELECT lastname, firstname, '"' + postalcode + '"' as postalcode FROM employees

The problem really lies in Excel and how it interprets numbers, it's not a SQL Server issue. The above may or may not alleviate the problem.

Go to Top of Page
   

- Advertisement -