0

I have a situation whereby I want to process files in an SSIS package but only files that are new and only files that match specific filename patterns.

Is it possible to use WMI to achieve this task by somehow looping through the resulset of a WMI query?

The WMI Data Reader task seems to be the closest contender but it can only write its results to a file (rather than to say a database table or in-memory recordset).

Has anyone had success doing this?

Rowan
  • 463
  • 3
  • 8
  • 20

1 Answers1

0

If you want to use the WMI Data Reader Task then the easiest solution would be to save the result to a file. Add a Data Flow Task that reads the file and inserts the data into the database.

However, another solution would be something like:

  1. Add a Foreach Loop with an Foreach File Enumerator, you can use an expression for the filename patterns.
  2. Process the files in a Data Flow Task
  3. If you are allowed to move the files then use a File System Task to move the file to a different folder so it won't be processed again.

If you can't move the files then you need some other way to determine if the file is already processed. If you only need to watch for new files and not modified ones then you could keep a record of which file has been processed in the database, or add a script task to check the modified date of the file and compare it to the last processed date from the database.

JodyT
  • 4,324
  • 2
  • 19
  • 31
  • Your suggestion i.e. writing to a file then reading that file, seems to be the most common suggestion. I find it odd that SSIS wouldnt provide other ways to store the resultset of the WMI task (like into an in memory recordset in the package or into a database table for example), but there you go.. – Rowan Jun 20 '13 at 22:14
  • I'm not sure if using the WMI task is the correct way to go though. What exactly is the reason to choose for WMI ? – JodyT Jun 21 '13 at 11:56