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
-
Click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.
-
In the Connect to SQL Server dialog box, enter the sa user name and password, and then click OK.
-
Click Query, and then click Results to File.
-
Enter and then execute the SQL statement.
-
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)
-
-
Click Save.
-
To open the report file in SQL Query Analyzer, click Open on the File menu.
-
In the Files of Type list, click All Files (*.*).
-
Click the report file, and then click Open.
Method 2: SQL Server Management Studio
-
Click Start, point to All Programs, point to Microsoft SQL Server 200X, (your version)and then click SQL Server Management Studio.
-
In the Connect to Server dialog box, specify the following settings:
-
Authentication: SQL Server Authentication
-
Login: sa
-
Password: Type the sa password.
-
-
Click Connect.
-
Click New Query.
-
On the Query menu, point to Results to, and then click Results to File.
-
Enter and then execute the SQL statement.
-
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)
-
-
Click Save.
-
To open the report file in SQL Server Management Studio, point to Open on the File menu. Then, click File.
-
In the Files of Type list, click All Files (*.*).
-
Click the report file, and then click Open.
Method 3: Support Administrator Console
-
Click Start, point to Programs, point to Microsoft Support Administrator Console, and then click Support Administrator Console.
-
In the Connect to SQL Server dialog box, specify the following settings:
-
Login Name: sa
-
Password: Type the sa password.
-
-
Click OK.
-
Enter and then execute the SQL statement.
-
On the File menu, click Export.
-
In the Save As dialog box, specify the following settings:
-
File name: Type a name for the file.
-
Save as Type: CSV Files (*.csv)
-
-
Click Save.
Note This .csv file can be opened in Microsoft Excel.