save the stored procedure resultset to excel file with proper display in excel file

  • How to save the stored procedure output(resultset) to excel file with resultset is properly displayed with its columns and also with proper formatting?

    My stored procedure executes inside the job created using SQL server Agent. In job if I set the output file as excel/csv file, than the data is not displayed in proper format.

    I also tried using BCP utility with excel file as output file, here also the formatting is not proper.

    I need a solution where the resulset is properly displayed in excel file with proper columns.

  • You could use SSIS to do this. You would want to do a Data Flow Task where your source query is the SP and your destination is the Excel file. Then you can schedule the Package in SQL Server Agent.

  • What kind of FORMATTING oyu are talking about ....is it like width of excel's column ??

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Formatting here means resultset to be displayed in proper columns in excel sheet.

  • INSERT INTO OPENROWSET ('MICROSOFT.JET.OLEDB.4.0', 'Excel 8.0; Database=D:\RFPSent\SENT_RFPs.xls;HDR=NO;IMEX=2', 'select * from [Venue_RFPs$]'

    ) SELECT * from tblvenue_RFP

    ------------------------------------------

    In above text [Venue_RFPs$] is a worsheet which has same column as table tblvenue_RFP

    is you follow same sequence for both WORHSHEET and TABLE ..the data will be correctly migrated

    i hope you will get your solution 🙂

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • U can write a simple .NET windows application and call urs stored procedure and send the result set to excel

    This is very simple.

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

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