| |
| ||||||
The Script Transformation part 2 ? as a SourceThis is a discussion on The Script Transformation part 2 ? as a Source within the BI Monkey forums, part of the CORTEX Blogs category; Fig 1: The Script Transformation In this post I will be covering using the Script Transformation as a Source . The sample package can be found here for 2005 and ... |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Guru Join Date: Jun 2009
Posts: 135
![]() | Fig 1: The Script TransformationIn this post I will be covering using the Script Transformation as a Source. The sample package can be found here for 2005 and guidelines on use are here. How can you use the Script Component as a source? One thing I skipped over in my previous post was that when you drag a Script Component on to the Data Flow surface, you are prompted as to whether you want to use it as a source, destination or transformation (the default). If you opt to use it as a source, it configures itself differently, so it has no inputs and a single output by default, to which you need to add columns, as below: Fig 2: Adding Output Columns to the Script TransformationTo populate rows, in the code you add a row to the Output Buffer using the AddRow method. You then assign values to the columns that you specified – the columns will be properties of the Output Buffer which will appear on Intellisense. Each time you hit the AddRow method you close off the previous row for that buffer. Below is a simple example generating some rows of data using a simple code loop. Each time the loop starts a iteration, I call the AddRow method for the Output0Buffer (the default one created when you set up the component). Then I set the values for the RowId and RowName columns using them as properties of the Output0Buffer. In this case, the code speaks a thousand words: Public Overrides Sub CreateNewOutputRows()So it’s not really that complicated to build a simple source. For those looking for some more advanced capabilities i’ve also included a couple of extra examples in the sample package. In the first (2b) I output rows to multiple outputs, sending a different set of rows to each output. In the second I read data from a table in the AdventureWorks database within the script source and modify it a little before sending it out to the data flow. It’s important to note you need to use a ADO .NET (Datareader) connections to access a database through a script’s own connection manager collection. Adding an ADO.NET connection manager for use in the script is simple – as shown below: Fig 3: Adding a Connection Manager to a Script ComponentNote the Connection Manager is from the Connection Managers for the package, not internalised to the Script Component itself. Where would you use the Script Component as a source? I’ve used it a couple of times to generate rows (such as default values for dimension tables), and the other common use would be when you need to access a data source that cannot be reached by standard SSIS components, but can be coded up to return a set of rows out of VB.Net / C#, for example a web service, or a particularly awkwardly formatted text file. MSDN Documentation for the Script Transformation can be found here for 2008 and here for 2005. If you are still struggling, try these additional resources:
Get More from the original blog... |
| | |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Script Transformation part 1 ? a simple Transformation | James Beresford | BI Monkey | 0 | 1st September 2009 02:01 PM |
| Getting File Information with the Script Task | James Beresford | BI Monkey | 0 | 26th August 2009 06:37 PM |
| The Slowly Changing Dimension Transformation, part 2 ? Type 2 Dimensions | James Beresford | BI Monkey | 0 | 11th August 2009 11:58 AM |
| The Slowly Changing Dimension Transformation, part 1 | James Beresford | BI Monkey | 0 | 28th July 2009 10:37 PM |
| Open Source | admin | Reporting Tips and Techniques | 5 | 7th February 2009 12:12 PM |
| | |
| | |