Tuesday, 17 April 2012

Custom SSIS Component: Foreach File Enumerator with regex

In some cases the standard wildcard filter in the Foreach File Enumerator isn't flexible enough. Try to get all files ending with a number or all files starting with an 'a' or 'b'. A filter based on a regular expression gives more freedom. See/vote this request at Microsoft Connect.

My .Net colleague helped me to create a File Enumerator where I replaced the standard wildcard filter by a regular expression filter. And we also added a sorting possibility.
Regular Expression Support























This Regex File Enumerator also alows you to select multiple extensions like *.xls + *.csv:
^.*\.(xls|csv)$

Disclaimer
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Downloads:
You can download a SSIS 2008 version on the download page. All my custom 2012 enumerators have an optional regex filter included.

Installation
The installer registers the DLL in the GAC and copies it to the ForEachEnumerators folder of SSIS (example: C:\Program Files\Microsoft SQL Server\100\DTS\ForEachEnumerators\). After that you have to close Visual Studio/BIDS because it caches the GAC on startup.

SSIS
The enumerator is automatically added to the Foreach Loop when you open a SSIS project.
The new enumerator




























Bugs or feature suggestions
Please contact me or leave a comment if you have any suggestions or found a bug in this Custom Enumerator.

3 comments:

  1. This is a very good start and a great piece to add to SSIS! It easily replaces the in-the-box file enumerator.

    ReplyDelete
  2. Does this work with SSIS 2005?

    ReplyDelete
    Replies
    1. No sorry, 2005 is not supported, but you can accomplish the same with a simple Script Task.

      Delete

Please use the SSIS MSDN forum for general SSIS questions that are not about this post. I'm a regular reader of that forum and will gladly answer those questions over there.

All comments are moderated manually to prevent spam.

Related Posts Plugin for WordPress, Blogger...