Save result to Excel file

Wilder Nick 40 Reputation points
2024-10-31T08:18:28.76+00:00

Is it possible to use sql command to save select result to Excel file directly?

SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. ZoeHui-MSFT 41,491 Reputation points
    2024-11-01T03:14:38.8366667+00:00

    Hi @Wilder Nick,

    It is a bit hard to do that directly.

    You may consider using SSIS to do that quickly.

    See the detailed steps:

    Import data from Excel or export data to Excel with SQL Server Integration Services (SSIS)

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 121.9K Reputation points MVP Volunteer Moderator
    2024-10-31T11:13:09.6366667+00:00

    Yes, but it is complicated. You need to install drivers etc, and it often leads to problems. I have never used it myself.

    The best way to get results from a query into Excel is to run the query from Excel. Go to the Data tab in the ribbon. Select GetData and the SQL Server database. In the dialog that pops up use the Advanced button to add a query.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.