store procedure result to excel

  • Please help in turning the store procedure result into excell and also to call this store procdure to batch file.

    The store procedure suppose is;

    USp_Sqlmonitor

  • SSIS can create Excel files from proc output.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I don't want to depend on sql agent or ssis. I want to create the procedure to execute and result output should be in excell so that I can call this procedure into batch file.

  • try using xp_cmdshell to BCP the results to an XLS file. Excel might complain that it is in the wrong format but should still open the file.

    exec xp_cmdshell 'bcp "exec database.dbo.usp_Sqlmonitor" queryout c:\temp\test.xls -c -T'

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • If you output the format as if it were a CSV (commas and quotes), and put an xls file extension on it, Excel will open it without complaining. I've done that before.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thank you all for your response. I will try it tomorrow.

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

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