Archive

Posts Tagged ‘vb.net’

Generate ROWNUM pseudo-column in SSIS

May 27th, 2009 NothingMan No comments

I posted earlier on how to generate a rownumber in SQL 2000, but that would not work as a source query in SSIS for some reason.  Without having to create a stored procedure or temp tables based on other temp tables, I wanted a simple way to generate this rownum in SSIS.  I was considering something with variable expressions, but then I found a way to do it with a Script Component.

Drag a Script Component Task into your DataFlow and connect it between your source and destination tasks.  Open it up and click “Inputs and Outputs”.  Double Click “Output 0″ and highlight “Output Columns” and click Add Column.  For this code to work, name that new column “rownum“.

Then open the script tab and click “Design Script” and paste this code over what is already there:

  

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

    Dim counter As Integer = 0

 

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

 

        Row.rownum= counter

        counter = counter + 1

    End Sub 

End Class

 

VN:F [1.5.8_856]

Rating: 5.0/5 (1 vote cast)
VN:F [1.5.8_856]
Rating: 0 (from 0 votes)
Categories: BI, Code, Tips Tags: , , ,

Putting VB.Net (2008) to sleep

May 6th, 2009 NothingMan No comments

While working on my geo-coding experiment, I realized that the Google web service stops allowing requests after a certain amount of submittals in a certain amount of time. I’d get about 30 successful results and then about 10-15 unsuccessful results.

The easiest way I could solve this problem was to send n requests and then sleep for a few seconds, and then continue.

So, this is how you put the program to sleep:

Add this code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

And call it like this:
Sleep(2000)

VN:F [1.5.8_856]

Rating: 3.0/5 (1 vote cast)
VN:F [1.5.8_856]
Rating: +1 (from 1 vote)
Categories: Code, Tips Tags: , , , , ,