How to create .csv or .rpt files from an SQL statement in Microsoft SQL Server

INTRODUCTION
This article describes how to create .rpt or .csv files from an SQL statement in SQL Query Analyzer, in SQL Server Management Studio, and in the Support Administrator Console.
More information
To create .rpt or .csv files from an SQL statement, use one of the following methods.

Method 1: SQL Query Analyzer

  1. Click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.
  2. In the Connect to SQL Server dialog box, enter the sa user name and password, and then click OK.
  3. Click Query, and then click Results to File.
  4. Enter and then execute the SQL statement.
  5. In the Save Results dialog box, specify the following settings:
    • Save In: Select a directory in which to save the file.
    • File Name: Type a name for the file.
    • Save as type: Report Files (*.rpt or *.csv)
  6. Click Save.
  7. To open the report file in SQL Query Analyzer, click Open on the File menu.
  8. In the Files of Type list, click All Files (*.*).
  9. Click the report file, and then click Open.

Method 2: SQL Server Management Studio

  1. Click Start, point to All Programs, point to Microsoft SQL Server 200X, (your version)and then click SQL Server Management Studio.
  2. In the Connect to Server dialog box, specify the following settings:
    • Authentication: SQL Server Authentication
    • Login: sa
    • Password: Type the sa password.
  3. Click Connect.
  4. Click New Query.
  5. On the Query menu, point to Results to, and then click Results to File.
  6. Enter and then execute the SQL statement.
  7. In the Save Results dialog box, specify the following settings:
    • Save In: Select a directory in which to save the file.
    • File Name: Type a name for the file.
    • Save as type: Report Files (*.rpt or *.csv)
  8. Click Save.
  9. To open the report file in SQL Server Management Studio, point to Open on the File menu. Then, click File.
  10. In the Files of Type list, click All Files (*.*).
  11. Click the report file, and then click Open.

Method 3: Support Administrator Console

  1. Click Start, point to Programs, point to Microsoft Support Administrator Console, and then click Support Administrator Console.
  2. In the Connect to SQL Server dialog box, specify the following settings:
    • Login Name: sa
    • Password: Type the sa password.
  3. Click OK.
  4. Enter and then execute the SQL statement.
  5. On the File menu, click Export.
  6. In the Save As dialog box, specify the following settings:
    • File name: Type a name for the file.
    • Save as Type: CSV Files (*.csv)
  7. Click Save.

    Note This .csv file can be opened in Microsoft Excel.
More information
Properties

Article ID: 860545 - Last Review: 04/05/2016 16:13:00 - Revision: 7.0

Microsoft Dynamics GP 2015, Microsoft Dynamics GP 2013, Microsoft Dynamics GP 2010, Microsoft Dynamics GP 10.0, Microsoft Dynamics GP 9.0, Great Plains eEnterprise 6.0, Great Plains Dynamics 6.0, Microsoft Great Plains eEnterprise 7.0, Microsoft Great Plains Dynamics 7.0, Microsoft Business Solutions–Great Plains 7.5, Microsoft Business Solutions–Great Plains 8.0

  • kbhowto kbexpertiseinter kbmbsmigrate KB860545
Feedback