Just a quick tutorial on using a script component as a source… Follow the link for screenshots.
First things first. Add a script component to the data flow. When prompted, select “Source” as the component type. (click on images for full sized version)
Image may be NSFW.
Clik here to view.
Next, for clarity’s sake, I’ll rename the default output. (An output simply contains a set of columns and will correlate to the green arrow on the data flow. The more outputs you have, the more green arrows you can use.) I’ll rename the default output, “Output 0″ to “MyOutput.”
Image may be NSFW.
Clik here to view.
Next, I’ll add an output column called, “MyColumn” and its type will be an integer. Be sure to change the type accordingly.
Image may be NSFW.
Clik here to view.
From here, we can edit the script by clicking on the script section on the left of the above window. From there click on the “Design Script…” button. Below is the setup:
Image may be NSFW.
Clik here to view.
Notice how when I type, I am automatically prompted for a list of available items to choose from. One of them is the column I added previously. Let’s pick the column and assign a value of 123 to it. Full script below:
For SSIS 2005:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub CreateNewOutputRows()
MyOutputBuffer.AddRow()
MyOutputBuffer.MyColumn = 123
End Sub
End Class
For SSIS 2008, it’s a bit different:
Visual Basic:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
Public Overrides Sub CreateNewOutputRows()
Output0Buffer.AddRow()
Output0Buffer.Column = 123
End Sub
End Class
C#:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void CreateNewOutputRows()
{
Output0Buffer.AddRow();
Output0Buffer.Column = 123;
}
}
You can close the script and then click OK on the script component dialog box. Now when you hook this source up to another component, you'll end up with one column with one row with a value of 123.