Metaphor
Metaphor

Reputation: 6405

Changing DelayValidation on multiple SSIS packages

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?

Upvotes: 3

Views: 2547

Answers (3)

billinkc
billinkc

Reputation: 61221

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

Upvotes: 2

user1533274
user1533274

Reputation: 33

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.

Upvotes: 0

Chaz
Chaz

Reputation: 1

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.

Upvotes: 0

Related Questions