How to create a csv file from a SQL command



1. If there is no SQL server management studio installed, you will need to install the Microsoft SQL CMD utility to connect to the database

2. Database login information

3. SQL command that will be used

4. SQLCMD options that will be used


Setup for (1):


1. Install the SQL native client (a pre-requisit of SQLCMD.exe) from


in the System requirement section.


2. Microsoft SQL CMD utility installer (SQLServer2005_SQLCMD.msi) is available from Microsoft at



3. See where SQL CMD is installed (usually in the folder called C:\Program Files\Microsoft SQL Server\90\Tools\Binn)


Set up for (4):


1. Test out the options for SQLCMD.exe to get the results that is needed in a DOS prompt until you get text file that you need.


For example:


sqlcmd.exe -Uxyzuser -Pxxypassword -o"c:\mytest.txt" -Q"set nocount on select * from EMPLOYEE" -Sxyzserver -dxyzdatabase -s"," -h"-1" -W


Note: For more information on the different options for the sqlcmd.exe, please see


2. Tips: Write down the options that works to be used in the Certify process


Certify setup


1. Add a step with the "Execute application" action, "Operating system" window , "System" window.

2. In the parameter "Application", select the SQLCMD.exe file.

3. In the parameter "Wait for application to finish", check the checkbox.

4. In the parameter "Command Line", enter the options that worked for you:


                For example: -Uxyzuser -Pxxypassword -o"c:\outputfile.csv" -Q"set nocount on select * from EMPLOYEE" -Sxyzserver -dxyzdatabase -s"," -h"-1" -W


5. Save the process and run the step. The file c:\outputfile.csv will be created.