SSIS: Execute a ssis package using .bat file

The code in the batch file should be like:

"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DTExec.exe" /f "D:\Package10.dtsx"

Please also make sure that the folder contains the batch file have a path without space within it. For example, if the full path of the batch file is c:\folder name\batchCommand.bat, and if we run it from a command window with command c:\folder name\batchCommand.bat directly, we will get the error:

'c:\folder' is not recognized as an internal or external command,operable program or batch file.

Thanks

Please find a sample batch file to run a package. Folder names have to be replaced.

D:
CD D:\FolderWhereThePackageisStored

 

@ECHO OFF
REM – LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
SET ERRORLEVEL=0

SET ErrorFilepath=ErrorLog\
SET sysdate=none
SET systime=none
FOR /F “tokens=2-4 delims=/ ” %%i in (‘date /t’) do set sysdate=%%i%%j%%k
FOR /F “tokens=5-8 delims=:. ” %%i in (‘echo.^| time ^| find “current” ‘) do set systime=%%i%%j%%k%%l
SET outputfile=%ErrorFilepath%%Jobname%_%sysdate%%systime%.log
REM * STEP 1 *
“C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtexec.exe” /F “d:\FolderWhereThePackageisStored\mypackage.dtsx” /Connection “my_Data_src;%Environment_variable%” /REPORTING E  >> %outputfile%

IF ERRORLEVEL 1 GOTO END

EXIT /B 0
@ECHO ON
:END

REM EXIT /B %ERRORLEVEL%
REM @ECHO ON
EXIT /B 1
Regards

Suresh M. Menon

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s