Emailing Query Results as a .csv file

  • Hi

    I upgraded from 7.0 to 2000 and had the problem where 2000 would send the results as ansi. I updated the registry to send as unicode. Now I have upgraded to 2005 and I am having the same problem where excel does not recognize the csv file. I updated the registry entries as before and still not working. I was using sql mail also updated the procedure to use Database mail.

    I am still getting the same result.

    Any ideas.

    Thanks

    Grant

  • I believe you are using xp_sendmail at this time in 2005...

    What is @separator  you are using... try using @separator= ','

    Please post your code...

     

    MohammedU
    Microsoft SQL Server MVP

  • Yes I tryed the ',' for the separator and when you try to open in excel is still says unrecognizeable fromat.

     

  • I will have to check it out more tommorrow.

    Thanks for your help.

    Grant

  • Here is the code that I am using.

    Exec

    master.dbo.xp_sendmail @recipients = 'gbradley@mwb.com',

    @message

    = 'Please do not reply to this Email. If any changes are required Please contact Grant Bradley at gbradley@mwb.com',

    @query

    = 'Select Custnbr,EquipID,Model,Serial,ProgramType,Prev_1_Date,Prev_1_Meter,Act_Mtr_Date,Actual_Meter,MacStatus from OMDsnapshot.dbo.CC_SuspectContractMeter_Report; Select * from OMDSnapshot.dbo.Srv_SuspectContractMeter_Report',

    @attachments

    = 'Suspect ContractMeters.csv', @subject = 'Suspect Contract Meters',

    @attach_results

    = 'True', @width = 2500

    Note; I have converted this file to use Database Mail and still get same result.

    Thanks

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply