Output in excel file format

  • Just curious, is it possible to get sql output directly onto a excel file using SSMS. I need it in a presentable format. Please share your inputs.

    Thanks.

    M&M

  • You could use OPENROWSET in your T-SQL statement which would write your output to an Excel workbook

    An example is:

    INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\MSSQL\Test.xls', 'SELECT * FROM [Sheet1$]')

    SELECT * FROM Keywords

    check BOL for examples

    An excellent article with sample code and a good explanation is:

    http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

    Hope this helps.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Oh. Thank you. I didn't know I will get an answer so quickly.

    Thank you very much.

    M&M

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

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