Export a result of a query to an excel file and sent to an e-mail

  • How can I Export a result of a query to an excel file and sent this filre to an e-mail?

    I need to do this in a Job in a specific hour of the day.

    Thanks for your help

    Viky

  • If you want to extract the data from the database in a format readable in Excel, use xp_sendmail extended stored proc. It can execute the query, put results into the file and send an email with this file as an attachment. Your first point of referece is:

    http://msdn.microsoft.com/en-us/library/ms189505.aspx

    Please note, don't try to create file with .xls extention. Extract your data as comma separated .csv file.

    You can setup scheduled SQL Job (SQL Server Agent) to execute your required task regulary at the required time.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Do you have a question about that or are you just makeing a random comment?

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

Viewing 3 posts - 1 through 2 (of 2 total)

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