DEPRECATED: Starting with SSIS+ 1.9, the .NET scripts are no longer maintained. Use the provided JavaScript alternative scripts instead.
Average: 4 (7 votes)


Overview

Script task to perform find and replace.


Setup

Script to:

  • Find specific combination in a Source or ...
  • Find specific combination in a Source, replace with another combination and store in a Target.

The Source and Target can be either a file or System.IO.Stream object. When you want to specify special control characters use "\" to escape it. For example carriage return is "\r" and line feed is "\n". Check sample SSIS package below.

When specified action is "Find", the task provides following parameters:

  • Find - combination to match.
  • StartIndex - position from where to start the search.
  • ResultVariable - package variable where to store found index.
  • IsSourceVariable - if true, Source is contained in package variable. Otherwise it is file connection manager (Boolean).
  • SourceVariable - source package variable (String). The variable type can be either string (source file path) or Object (Stream).
  • Source - source file connection manager (Connection).

When specified action is "FindAndReplace", the task provides following parameters:

  • Find - combination to match.
  • Replace - combination to use as a replacement for a match.
  • IsSourceVariable - if true, Source is contained in package variable. Otherwise it is file connection manager (Boolean).
  • SourceVariable - source package variable (String). The variable type can be either string (source file path) or Object (Stream).
  • Source - source file connection manager (Connection).
  • IsTargetVariable - if true, Target is contained in package variable. Otherwise it is file connection manager (Boolean).
  • TargetVariable - target package variable (String). The variable type can be either string (source file path) or Object (Stream).
  • Target - target file connection manager (Connection).

Requirements

Depends on COZYROC Script Task Plus for implementing parameters user interface.


Demonstration

Download sample SSIS package for a demonstration of the task, replacing Windows text file line ends (carriage return + line feed) with Unix text file line ends (only line feed).


Library references

  • System
  • System.Data
  • Microsoft.SqlServer.ScriptTask
  • Microsoft.SqlServer.ManagedDTS
  • CozyRoc.SSISPlus

ScriptMain