Using a Variable to Store the WMI Data Reader Task's Output

Downloads
102564.zip

In SQL Server Integration Services (SSIS) packages, you can use WMI Data Reader tasks to obtain Windows Management Instrumentation (WMI) data from computers. In "Use SSIS to Access WMI Data on Multiple Servers," this data is stored in a file. Alternatively, you can store it in a variable.

The 102564.zip file includes an SSIS package—WMICollectDrivesInfo_Var.dtsx—that uses a variable named WMIOut to store the WMI Data Reader task's output. To obtain the 102564.zip file, click the 102564.zip hotlink at the top of the page.

To create the WMICollectDrivesInfo_Var package, you need to do things differently in three steps:

  • In step 2, you need to define an additional variable named WMIOut, which will store the WMI Data Reader task's output. You also need to specify a different scope for all three variables. Figure A shows the information you need to enter for each variable.

    Figure A: Entering the three variables


  • In step 4, you only have to create the WMI Connection Manager and OLE DB Connection Manager. The File Connection Manager and the Flat Connection Manager aren't needed.
  • In step 8, you need to use a Script component rather than a Flat File Source inside the Data Flow task.

To create a Script component, drag the Script component icon from the Toolbox's Data Flow Transformation section to the Data Flow design surface. When asked, select Source for the Script Component Type.

To configure the Script component, right-click it and choose Edit to open the Script Transformation Editor. On the Inputs and Outputs page, expand Output0 by clicking the + sign. Select Output Columns. Click the Add column button and add the following columns:

  • Name: Data Type= string \[DT_STR\]
  • SystemName: Data Type= string \[DT_STR\]
  • FreeSpace: Data Type= string \[DT_STR\]
  • Size: Data Type= string \[DT_STR\]

On the Script page, enter User::WMIOut in the ReadOnlyVariables field. Click the Design Script button and insert the SSIS_User_Script_Component script, which you'll find in the 102564.zip file.

For additional information on how Script components work in SSIS packages, see the web-exclusive article "Scripting Data Flow in SQL Server Integration Services".

Discuss this Article 1

mattgvt
on Dec 26, 2012
The download link appears to be broken. I'd like to try implementing this using the variable as opposed to the file used in the previous article. The script code or the download link would be helpful. Thanks

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottOur Experts will show you:
• Common SQL Server
Problems
• Best Practices for T-SQL
• SQL Server Integration
Services
• Database Development

Come See Michael Otey & Tim Ford in Person!

Early Registration Now Open

From the Blogs
May 21, 2013
blog

A Common Misconception about MAXDOP

Out of the box, SQL Server is (and has been) able to take advantage of multiple processors/cores without any effort on behalf of administrators....More
May 9, 2013
blog

My ISO 8601-Compliant Signature 2

My family recently just "officially" announced that we're in the process of adopting a child from South Africa. We're quite excited, of course, but there's a ton of paperwork to do—along with the need for gobs of signatures....More
May 8, 2013
blog

Use SSIS for ETL from Hadoop

In this blog post, Mark Kromer walks you through using SSIS as a way to use ETL techniques using Microsoft's Hadoop on Windows (HDInsight) as a source using Hive connectors...More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.