How to export SQL table data into Excel file

  • Hi,

    I want to export Data in SQL table into Excel sheet using SQL query or

    stored procedure.(I dont want to use SSIS or any manual process)

    Is there any way?

    pls help.

    Thanx in advanced.

  • Hi,

    you can use OPENROWSET to import from excel eg:

    SELECT *

    INTO tblMyTable

    FROM

    OPENROWSET('Microsoft.Jet.OLEDB.4.0'

    ,'Excel 8.0;Database=C:\myspreadsheet.xls'

    ,'SELECT * FROM [Sheet1$]'

    )

    James Howard

  • I am not sure if there is a way with T-SQL to write into Excel, but you can use a scripting language like VBScript or probably PowerShell to read from a db table and write it into Excel.

    Joie Andrew
    "Since 1982"

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

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