.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

Script Component Transformation with Lookup

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :Sql Server
 

Hi Guys,

I have the following recordset in the data flow.

Col0 Col1 Col2
Itm VM RY FF    128.00
Itm DGOLRG SODA/JFL

View Complete Post


More Related Resource Links

Script Component Transformation as a Lookup

  
Hi Guys, I have the following code from my Script Component as a Lookup. Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper Imports System.Collections.Generic Imports System.Data.SqlClient <Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute()> _ <CLSCompliant(False)> _ Public Class ScriptMain     Inherits UserComponent     Dim connMgr As IDTSConnectionManager100     Dim sqlConn As SqlConnection     Dim sqlCmd As SqlCommand     Private vTaxAmt As Decimal     Private vDelChgAmt As Decimal     Public Overrides Sub AcquireConnections(ByVal Transaction As Object)         connMgr = Me.Connections.Connection         sqlConn = CType(connMgr.AcquireConnection(Nothing), SqlConnection)     End Sub     Public Overrides Sub PreExecute()         sqlCmd = New SqlCommand("SELECT ItemTypeCode FROM LkpItemDepartment WHERE (ItemDeptCode = @ItemDeptCode) AND (ItemClassCode = @ItemClassCode)", sqlConn)                 With sqlCmd.Parameters   

Using Script Component For Lookup

  

Hey everyone. First let me say that I'm new to the forums and new to SSIS.  I've been a .Net developer since the beginning but never used SSIS until now.  With that said, here is my issue. 

My Problem:  I have a situation where I have data coming from a mainframe Db2 source and one of the fields is a state column.  It can hold either the state code (NC) or the name of the state (North Carolina).  Our target table will only hold the 2-character state code. So I need to check the State column for each record and if the length is greater than 2 characters, I need to do a lookup and return the state code for the given state name.

Possible Solutions:

I initially was going down the path of using a Conditinoal-Split task to split the records based on the state column being 2 characters or bigger, with a Fuzzy Lookup for the state name and then a Merge task to merge the two sets of records back together before inserting into my target.  However, I was in an SSIS training class this past week and ran this solution by my instructor and he thought that a Script Component would be better for this kind of transformation.

So I've been working on my second solution using a Script Component Transformation task and my input was the State column and my output was the transformed state code.&n

script component "transformation"

  

Hi All,

Can anybody show me an example how to create new Derived Column ( e.g. ABC-Column-Name = "M" - its value ) using Script Component "transformation" the same as create a using Derived column Task?

 

Thanks

Kumar


Script Component as Transformation

  

Hi Guys,

I have these codes that gives my the desire output before. These codes scanned the records and if the current RowType <> "TENDER" and previousC1 = "TENDER", assign the value of RowType = "TOTAL" to a variable ouput.

Before, if the RowType is "TENDER", it means that its the end of a transaction group.

<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute()> _
<CLSCompliant(False)> _
Public Class ScriptMain
  Inherits UserComponent
  Private dt As DataTable
  Private previousC1 As String = String.Empty
  Public Overrides Sub PreExecute()
    MyBase.PreExecute()
    dt = New DataTable()
    dt.Columns.Add("BusinessDate")
    dt.Columns.Add(&qu

How to execute a parameterized stored procedure using ssis dataflow script component transformation

  

Hi All,

Can any body send code for how to execute a parameterized stored procedure  using ssis dataflow script component transformation using .net

I know how to execute storedproc using control flow script task, but I need using ssis dataflow script component transformation.

Thanks,

RH


sql

SSIS Lookup Transformation Issue

  
I am having a strange issue, In my data flow i have a Lookup Transformaton which will match on key columns of the fact and is followed by a condetional split that would deside if it should insert (old db destination) or go to update (oledb command) or ignore if no change. I have packages running for the last 1 year with the same logic. But in the recent packages I am experiencing a problem.  example: Key columns for join are - type_no (varchar 16) with all numeric values except one record wihh ' '(space) in it  and type_cd (decimal(18,0)) with values(0,1,2,3,4,5) It worked fine when I test the package. After couple of day running in schedule I get integrity violation and huge file with failed records which are supposed to be blocked at the condetional split as they are already in the fact. When i add a data viewer what i found is for all the llokup columns its having nulls (no match found). Workaround that is working for me for now is - I select full cash and say ok in the lookup transofrmation and again open it and set it back to no cash. Then it starts working as expected. Did anyone come accross this kind of issue? is the some standard that I have to follow to make sure this doesnot happen again  

Script Component HELP!

  
Hi Guys, I have some recordset in the data flow. CURRENT Column1 Column2 Column3 Column4 Column5 Column6 Dine In DISCOUNT 20100824 121618 1859 37 Dine In TAX 20100824 121618 1859 -15.8 Dine In TOTAL 20100824 121618 1859 6.77 Dine In TENDER 20100824 121618 1859 63.2 Dine In TAX 20100824 121618 1859 63.2 Dine In DISCOUNT 20100824 121618 1860 37 Dine In TAX 20100824 121618 1860 -15.8 Dine In TOTAL 20100824 121618 1860 6.77 Dine In TENDER 20100824 121618 1860 63.2 Dine In TAX 20100824 121618 1860 63.2 I want to rename the second "TAX" in Column2 with the value of "DELIVERY CHARGE" and i was thinking on how to do this using script component. TARGET Column1 Column2 Column3 Column4 Column5 Column6 Dine In DISCOUNT 20100824 121618 1859 37 Dine In TAX 20100824 121618 1859 -15.8 Dine In TOTAL 20100824 121618 1859 6.77 Dine In TENDER 20100824 121618 1859 63.2 Dine In DELIVERY CHARGE 20100824 121618 1859 63.2 Dine In DISCOUNT 20100824 121618 1860 37 Dine In TAX 20100824 121618 1860 -15.8 Dine In TOTAL 20100824 121618 1860 6.77 Dine In TENDER 20100824 121618 1860 63.2 Dine In DELIVERY CHARGE 20100824 121618 1860 63.2 Thanks in advance,

Script Component

  
Hi Guys,   I am newbie and never done coding in vb. script, I am using SSIS component for this. I am using below code to allow user to enter storeid and change file name inside the directory from filename.ajk to storeid_filename.ajk.   Example:  01012010.ajk 02012010.ajk 03012010.ajk Once the user enter the storeid all the files in that particular directory will change to like this automatically 192572_01012010.ajk 192572_02012010.ajk 192572_03012010.ajk Now all I want is to change the file name from 01012010 to 20100101. So once the user enter the storeid it has to change it to  192572_20100101.ajk 192572_201001012.ajk 192572_20100103.ajk     Please help me guys its a urgent help.       Public Sub Main() ' ' Add your code here         '         Dim InputFilePath As String         Dim StoreNo As String = InputBox("Enter Store No", "StoreNo")         InputFilePath = Dts.Variables("strInputFolder").Value         Dim strFileSize As String = ""           Dts.Variables("StoreNo").Value = StoreNo         Dim di As New IO.DirectoryInfo(InputFilePath)         Dim aryFi As IO.FileInfo

Question using Script Component

  
Hi Guys, I have this records on my dataflow.   Column1 Column2 Column3 ITEM 1 P ITEM 2 S ITEM 3 N ITEM 4 O ITEM 5 M ITEM 6 MC ITEM 7 MAO ITEM 8 MT ITEM 9 P ITEM 10 S ITEM 11 N ITEM 12 O ITEM 13 M ITEM 14 MC ITEM 15 MAO ITEM 16 MT    I want to add a new column that based on these condition. 1. If Column1 and Column3 is "S", "N", "O", "P" then Column4 value is  1 2. If Column1 and Column3 is "M" then Column4 values is 0 3. if Column1 is not "ITEM" then Column4 value is NULL 4. If Column1 and Column3 is "MC", "MAO" , "MT" then get the last column2 value place for Column4.  Column1 Column2 Column3 Column4 ITEM 1 P 1 ITEM 2 S 1 ITEM 3 N 1 ITEM 4 O 1 ITEM 5 M 5 ITEM 6 MC 5 ITEM 7 MAO 5 ITEM 8 MT 5 ITEM 9 P 1 ITEM 10 S 1 ITEM 11 N 1 ITEM 12 M 12 ITEM 13 O 1 ITEM 14 MC 1 ITEM 15 MAO 1 ITEM 16 MT 1  I have the following script to get some of the conditions, but im stuck in the last one with the "MC, MAO, MT" in Column3.  If Column1 = "ITEM" And Column3 = "S" Or Column3 = "N" Or Column3 = "O" Or Column3 = "P" Then             Column4 = "1" &

Error in Script component in the Data Flow Task

  
Hi, I need a small help. This is what i require. I need to generate a auto increment number using script component and assign it to target column. use db1 go create table src (name varchar(10) ) insert into src select 'A' union all select 'B' union all select 'C'   create table trg (id int, name varchar(10) ) while loading the trg table, i need to generate a auto increment number and then load it to target. Finally, my trg table data should look as follows id name 1  A 2  B 3  C This is what i have done inside the package. step1 : declared a global variable "tmp" of int32 step2 : created a connection manager pointing to "db1" database step3 : drag n drop data flow task step : inside the data flow task , i have the following        OLEDB Source  (select name from src)           |        Script Component (i have added a new Output column "v_id" of int datatype in INPUTS AND OUTPUTS page)           |        OLEDB Destination In the Script page in Script component , in ReadWriteVariables | User::tmp, I have chose Visual Basic 2008 and clicked the EDit script and inside the Editor this and inisde the below routine i have added only two

Script Component Question

  
Hi Guys, I got this recordet from a flat file. C1 C2 ITM 0 ITM 0 ITM 0 ITM 0 TX 0 DC 0 TOT 1 TN 0 ITM 0 ITM 0 ITM 0 ITM 0 TX 0 DC 0 TOT 2 TN 0 The requirement is if C1 = TOT, then the C2 value remains the same. If C1 <> TOT then C2 value is equal to C1 = TOT value. C1 C2 ITM 1 ITM 1 ITM 1 ITM 1 TX 1 DC 1 TOT 1 TN 1 ITM 2 ITM 2 ITM 2 ITM 2 TX 2 DC 2 TOT 2 TN 2 The sorting is fix. TOT always come first before the TN. Can a script component do this and how? Thanks,

SSIS script component bugs at around 10k rows

  
I'm trying to load a dimension table from a tab delimited file to a parent-child table. I have made a script like this: public override void Input0_ProcessInputRow(Input0Buffer Row) { String level0 = null, level1 = null, level2 = null, level3 = null, level4 = null, level5 = null; while (!Row.EndOfRowset()) { if (Row.Description_IsNull || Row.Description == "") { if (!Row.NextRow()) break; continue; } if (!Row.Level0_IsNull) { Row.ID = Row.Level0; Row.ParentID = null; level0 = Row.Level0; Row.Description = Row.Description; } else if (!Row.Level1_IsNull) { Row.ID = Row.Level1; Row.ParentID = level0; level1 = Row.Level1; Row.Description = Row.Description; } else if (!Row.Level2_IsNull) { Row.ID = Row.Level2; Row.ParentID = level1; level2 = Row.Level2; Row.Description = Row.Description; } else if (!Row.Level3_IsNull) { Row.ID = Row.Level3; Row.ParentID = level2; level3 = Row.Level3; Row.Description = Row.Description; } else if (!Row.Level4_IsNull) { Row.ID = Row.Level4; Row.ParentID = level3; level4 = Row.Level4; Row.Description = Row.Description; } else if (!Row.Level5_IsNull) { Row.ID = Row.Level5; Row.ParentID = level4; level5

Script Component Help

  
Hi Guys, I have the following recordset in my dataflow.   Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8 Col9 Col10 Col11 Col12 Col13 Col14 Col15 Col16 Col17 Col18 Delivery       DELIVERY 1234567 1 Ewoks 0 0 0 0 0 0 0 0 0 0 0 0   Delivery       ITEM   20100804 111524 25 1 1 4001 5 1 5 1 0 JED SPAGHETTI 1 42   Delivery       TAX   20100804 111524 25 1 1 0 0 0 0 0 0 TAX 1 92.18   Delivery       TOTAL   20100804 111524 25 1 1 5 0 7 1 0 1 Delivery       1 489.5   Delivery       TENDER   20100804 111524 25 1 1 0 1 1 0 0 0 CASH 1 489.5   DELIVERY 6671775   Sari-Sari Store 0 0 0 0 0 0 0 0 0 0 0 0     DELIVERY 6671775   Sari-Sari Store 0 0 0 0 0 0 0 0 0 0 0 0     PaidOut-Refd KPP Dep PAIDOUT   20100804 104450 1304 1 -1 7 0 0 0 0 0 PaidOut-Refd KPP Dep 1 500     Conditions: If Col1 <> "DELIVERY" And Col2 = "DELIVERY" Then Col18 = Col3 + "," + Col4 Where Col2 = "TENDER" If Col1 = "DELIVERY" And Col2 = "DELIVERY" Then Col18 = Col3 + "," + Col4 Where Col2 = "TENDER" If Col1 in first row = "DEL

SQL Server 2008 Script Componant Error - [SSIS.Pipeline] Error: component "Script Comp Name" (48) fa

  
Hi All,   I am facing one strange issue in SSIS 2008. I have developed one SSIS package which is importing excel data into SQL Server 2008. This Package contains some Scirpt componants. This package is working fine on Windows XP machine but when I am trying to run on Windows 2003 server it gives me error "[SSIS.Pipeline] Error: component "SCR RDSTableRelation" (48) failed the post-execute phase and returned error code 0x80004002". Surprising thing is that if on windows server 2003server  if I drag a new script componat and paste the previous script code itself then it works fine. Even if I copy-paste the existing script componant and give source-destination connectino to this new script componant then also it works.

Script Component - Change One Row Input to Multiple Row Output

  
Hi All I am new to SSIS, and looking for help. I do not know if it is possible, but I like to try using the "Script Component" to change a input like this:   1234 1235 1236 ...   to and output like this:   1234, Value1 1235, Value2 1235, Value3 1235, Value4 1236, Value5 ...   Depending of the input value, 1 or more Rows are pushed out the Output, Like the value 1234 -> result in 1 Row in the output, where the value 1235 -> result in 3 rows in the output. Is this possible to do in a Script Component?? If it is how do you program such behavior? Do some good sources to learn SSIS exist out there?? I think it is not easy to find information. Peter Schwennesen

LookUp Transformation

  
Hi All I have a flatFile which has 3 columns. Serialnumber,name,string. And i have a DB Table called dbo.devices and i have two columns in it deviceID,Serialnumber. In this table for each serialnumber ,deviceid is a identity generated column. Now i want to replace the SerialNumber Column in the FlatFile with the Correspoding deviceID column in the DB Table. My flat files will have app 20ooo Rows and i have  7000 Files. How can i accomplish this Task. This is just a one time task but i want it to be done in faster way. Am planning to use a Lookup Transformation For this
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend