I have a SSIS package to loading some data based on the month and I want to call the package via windows batch file. Here is what's in the cmd file which is working fine now:
CD /D C:\Program Files\Microsoft SQL Server\100\DTS\Binn
DTExec.exe /f "E:\APAutomation\SSIS\AP\ActualDataImport_Console_PL.dtsx" /SET \Package.Variables[User::ActualMonth].Properties[Value]; "9"
Now I replace the 9 with a variable so to make it less hardcoded
CD /D C:\Program Files\Microsoft SQL Server\100\DTS\Binn
set ActualMonth = 9
DTExec.exe /f "E:\APAutomation\SSIS\AP\ActualDataImport_Console_PL.dtsx" /SET \Package.Variables[User::ActualMonth].Properties[Value]; "%ActualMonth%"
however, this won't work: this is the error msg:
C:\Program Files\Microsoft SQL Server\100\DTS\Binn>DTExec.exe /f "E:\APAutomatio
n\SSIS\AP\ActualDataImport_Console_PL.dtsx" /SET \Package.Variables[User::Actual
Month].Properties[Value]; ""
Microsoft (R) SQL Server Execute Package Utility
Version 10.50.1600.1 for 64-bit
Copyright (C) Microsoft Corporation 2010. All rights reserved.
Argument ""\Package.Variables[User::ActualMonth].Properties[Value];"" for option
"set" is not valid.
C:\Program Files\Microsoft SQL Server\100\DTS\Binn>pause
Press any key to continue . . .
I also tried:
set ActualMonth = "9"
DTExec.exe /f "E:\APAutomation\SSIS\AP\ActualDataImport_Console_PL.dtsx" /SET \Package.Variables[User::ActualMonth].Properties[Value]; %ActualMonth%
it threw me the same error msg. Pls help!
I think your specific problem is the spaces...
use this
set ActualMonth=9
instead of this:
set ActualMonth = 9
What you're doing is basically setting a package config from a batch file. It might work better if you set up the package to read from a package config file and put your month number in there.
Related
Kindly help where i am doing wrong,
E:\Program Files\Microsoft SQL Server\120\DTS\Binn>DTExec /F "D:\SSIS\Import\connection_manager.dtsx" /set "\Package.Variables[User::packagedir].Properties[Value]";"D:\SSIS\Import\\" /set "\Package.Variables[User::PRODDB_connectionstring].Properties[Value]";"Data Source=*********;Initial Catalog=PRODDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;Application Name=SSIS;" > "C:\Users\PROD\Desktop\SSIS\log.txt"
Getting Following Error :
Argument
""\Package.Variables[User::PRODDB_connectionstring].Properties[Value];Data
Source=*********;Initial
Catalog=PRODDB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto
Translate=False;Application Name=SSIS;"" for option "set" is not
valid.
You need to encapsulate your strings with \ before string start. And then you should just write .Value after your parameters instead.
#ECHO OFF
ECHO.
ECHO This is a batch file
ECHO.
DTEXEC.EXE /F "C:\Users\thoje\Documents\Visual Studio 2015\Projects\Integration Services Project8\Integration Services Project8\Package30.dtsx" /set \Package.Variables[User::packagedir].Value;\""D:\SSIS\Import\\"\" /set \Package.Variables[User::conn].Value;\""Data Source=EGC25199;Initial Catalog=LegOgSpass;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False"\"
PAUSE
CLS
I need to run the SSIS 2012 package through batch file,Package is executing fine in command prompt,But not able to pass parameter run time values via commands ,While run in DOS prompt ,
throwing error like
SET is not recognized as command
"C:\Program Files (x86)\Microsoft SQL Server\120\DTS\ Binn \DTExec.exe" /f "D:\SSIS Deployment\Test Reports\Move Files . dtsx"
/SET \Package. Variables[Report Root Path].Value;"D:\\Development\\PPY"
/SET \Package. Variables[Run Status].Value; "NORM";
I see there are space "Package. Variables"
Just remove the space and try .
remove the last ; and try it again.
this works fine for me:
c:\tmp>dtexec /f "test.dtsx" /SET \Package.Variables[a].Value;"a" /SET \Package.Variables[b].Value;"b"
howerver, this one will give me a similar error:
c:\tmp>dtexec /f "test.dtsx" /SET \Package.Variables[a].Value;"a" /SET \Package.Variables[b].Value;"b";
Argument ""\Package.Variables[b].Value;b;"" for option "set" is not valid.
I am trying to dynamically set the connection string of my SSIS package through DTEXEC.exe
My CMD file consists of following command.
"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DTEXEC.exe" /f
"D:\ABC\XYZ\Packages\ABCD.dtsx" /CHECKPOINTING OFF /REPORTING V /CONSOLELOG/Conn
"Configurations;'"Data Source=XXXXXX;Initial Catalog=YYYY;Provider=SQLNCLI10.1;Integrated
Security=SSPI;Auto Translate=False;'"" /SET
"\Package.Variables[User::TargetEnvironmentId].Properties[Value]";"2"
If i take out connection string part it works fine but when i add
/Conn "Configurations;'"Data Source=XXXXXX;Initial Catalog=YYYY;Provider=SQLNCLI10.1;
Integrated Security=SSPI;Auto Translate=False;'""
This it throws exception and says INVALID
Is the name of your connection manager called "Configurations"? I can only assume that is the case. Give the following a try:
/CONNECTION "Configurations";"\"Data Source=XXXX;Initial Catalog=YYYY;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;\""
I always find it easier to use DTExecUI to create the script, have you tried doing that?
Either that or set the connection string as a variable and pass that through DTExec
When running DTEXEC I am getting "The connection xxxx is not found".
I beleieve this is because the connection managers are located at Project level and not within the package itself.
When running DTEXECUI - these connection managers are not displayed.
Is the only way to move them into the package - seems a bit weird as what is the point of allowing them a project level if you then have to move them to use them with DTEXEC.
Thanks
Here is the command line syntax you asked for:
C:\Users\Administrator>dtexec /FILE "\"F:\SSIS Projects\HESA\HESA\01 - Upload Metadata Files To Oracle.dtsx\"" /SET "\Package.Variables[User::varYear.Properties
[Value]";"1999" /CHECKPOINTING OFF /REPORTING EW /CONSOLELOG SMT
Your assumption that
the connection managers are located at Project level and not within the package itself
is exactly the problem. But there is a solution:
build the project to get a .ispac file
instead of invoking dtexec with /FILE you have to invoke it with /Project and /Package, like this:
/Project "path to you .ispac file, resulting from building the project"
/Package "Name of your package.dtsx"
Please, be aware that if you provide the whole path to your .dtsx package the execution will fail with very criptic SQLDUMPER error messages.
I have a project with about 150 packages in SSIS 2012. One of them is the entry point and the rest are called somewhere down the line from the main. Each of them creates its own table in the destination if one does not exist. I've found that I need to set DelayValidation to True for this to work, but loathe the job of doing it 150 times. Is there a way to have this property propagate or anything other than making a change to all the packages?
You can make this change by using the .NET library. Below is a PowerShell script that looks at all the packages in a given folder. If the DelayValidation property is false, then it will change it to True and save the package.
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SQLServer.ManagedDTS") | Out-Null
$folder = "C:\sandbox\StackOverflow\StackOverflow\obj\Development"
$app = New-Object Microsoft.SqlServer.Dts.Runtime.Application
foreach($current in (Get-ChildItem $folder -Filter "*.dtsx").FullName)
{
Write-Host $current
$package = $app.LoadPackage($current, $null)
if ($package.DelayValidation -eq $false)
{
$package.DelayValidation = $true
$app.SaveToXml($package, $null)
}
}
Caveats
Never run automated code without testing that you have version control.
This only changes the Package's DelayValidation. Each Container and Task have their own DelayValidation property that may need to be updated
2017+ note
A user noted
SaveToXml function needs 3 parameter in SQL Server 2017.
That would make this SaveToXml look like
$app.SaveToXml($current, $package, $null)
The Documentation indicates this has been so since 2016.
They further noted,
As a Developer without installing SQL Server like me, need located your Microsoft.SQLServer.ManagedDTS.dll file explicitly
That would replace the first line's LoadWithPartialName to LoadFile with an explicit path like
([Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\SSIS\140\Binn\Microsoft.SqlServer.ManagedDTS.dll") | Out-Null)
Note the exact path will vary based on your installed tooling. I tend to use the dir /s /b (directory, search subfolders, bare format) command to find things so
C:\>cd "\Program Files (x86)"
C:\Program Files (x86)>dir /s /b Microsoft.SqlServer.ManagedDTS.dll
C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\CommonExtensions\Microsoft\SSIS\150\Binn\Microsoft.SqlServer.ManagedDTS.dll
C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\PublicAssemblies\SSIS\150\Microsoft.SqlServer.ManagedDTS.dll
Here we can see I have two ManagedDTS.dll both for the 150 (2019?) release of SQL Server
I've found the quicker way, which is finding DelayValidation">0< and replacing with DelayValidation">-1< in the code of each individual package. It is quicker than going item by item and alter the properties, but you still have to do it for each package.
Setting DelayValidation">0 to DelayValidation">-1 works in SSIS 2008 and SSIS 2008 R2, but it doesn't exists with SSIS 2012. By default, components in SSIS 2012 doesn't have the item - DTS:DelayValidation. Once you've set the component's DelayValidation to True, the following is added - DTS:DelayValidation="True". I'm using Visual Studio Ultimate 2012.