DTEXEC: How to execute SSIS Package

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditShare on Tumblr

This article is related with SSIS Package: How to export data to CSV file

DTEXEC Utility

The DTEXEC command prompt utility is used to configure and execute SSIS packages. It provides access to all the package configuration and execution features, such as connections, properties, variables, logging and progress indicators.

Run DTEXEC from BATCH file

To see all DTEXEC parameters open Command Prompt (Windows+R, type “cmd” and press Enter) and type dtexec /?
CMD dtexec parameters
For this example I am going to use only 2 parameters:
/F[ile] the path where the Package file (.dtsx) is located
/Conf[igFile] the path where the Configuration file (.dtsConfig) is located
… and 2 folders:
C:\ExportedDocuments\Temp\ location where I save the exported CSV file
C:\ExportedDocuments\ location where I move the exported CSV file after I rename it (add the date at the end of the file’s name)
If you have never written a BATCH file before please consider this articole How to write a Batch file. This will help you understand my script file.
Open a TXT file and COPY/PASTE the below code:

@echo off 
REM Check if there is an already temporary file, if YES delete it
if EXIST C:\ExportedDocuments\Temp\exported.csv goto STEP1
ECHO Temporary file exists, delete file
DEL C:\ExportedDocuments\Temp\exported.csv
REM Execute the SSIS Package with Configuration file
dtexec /f"C:\ExportCSV.dtsx" /conf"C:\configuration.dtsConfig"
REM Get current date: DDMMYYYY format
SET dt = %date:~-10,2%%date:~-7,2%%date:~-4,4%
SET TEMP = C:\ExportedDocuments\exported.csv
SET PATH = C:\ExportedDocuments\Exported_%dt%.csv
REM Copy the temporary CSV file to a new location with a different name
REM Delete the temporary file

Save as batchfile.bat and run it.