How to Export Query result to CSV file by Using Sql Script

RAMA KRISHNA MANDALAPU 0 Reputation points


I need to store Sql query result to csv file in a given path.
I need to this task in SQL Agent.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,038 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 72,226 Reputation points MVP

    Check out this blog post from Luca Zavarelli on how to do it from PowerShell:

    Might be less heavy artillery than SSIS.

    1 person found this answer helpful.
    No comments

  2. Yitzhak Khabinsky 20,546 Reputation points

  3. PercyTang-MSFT 2,921 Reputation points Microsoft Vendor


    In addition to the above two answers, you can also refer to this link. There are a lot of targeted methods inside.

    Best regards,

    Percy Tang

    If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.