SQL Mail

  • Is there a way to output the results of a query using SQL mail directly to an Excel Spreadsheet and if so, how ?

    Thanks

  • No direct way, but you can setup a DTS pack to generate a .xls file by specifying the same query and let sqlmail pick the file and email.

    EXEC master..xp_sendmail

    @recipients = 's2v'

    ,@message = ' Pls find the Execel sheet'

    ,@subject = 'Execl Attached'

    ,@attachments = 'c:\test.xls'

    The path is from the server.

    Shas3

  • You could save the file as comma-delimited and a .csv extension. Most pc's have excel assigned as the default application to open comma seperated files.

  • I have a procedure to BCP from a view and export the data into a spreadsheet. Works like a charm.

    EXECUTE master..xp_cmdshell 'BCP Database..ViewName out "E:\FullPath\Spreadsheet.xls" /c /Sserver /Uuser /Ppassword'

    Linda

  • As Linda said, BCP is also another option in place of DTS

    Shas3

  • if you have same query then you can use OSql utility

    Osql -o option can be used for get the query resulet in .xls file.

    and u can create a .Bat file to execute this command put the schedule thru OS.

    for more detail see BOL.

    Manoj Kumar

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

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