Worksoft Community

How to create a csv file from a SQL command

Wiki Table of Contents

Page Details

First published by:
Yujira
on 2 Nov 2010
Last revision by:
Yujira
on 3 Nov 2010
1 person found this article useful.

100% of people found this useful
How to create a csv file from a SQL command

 

Pre-requisite:

 

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

 

http://www.microsoft.com/downloads/en/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en#SystemRequirements

 

in the System requirement section.

 

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

http://www.microsoft.com/downloads/en/details.aspx?familyid=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en

 

 

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 http://msdn.microsoft.com/en-us/library/ms162773.aspx.

 

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.

 

Recent Comments

Leave the first comment for this page.
©2009-2011 Worksoft, Inc.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems