SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to map transformation using script task in SSIS?


How to map transformation using script task in SSIS?

Author
Message
guptaopus
guptaopus
Old Hand
Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)

Group: General Forum Members
Points: 394 Visits: 244
Hi,
I have a DTS package which is copying records from MS access database to SQL server database..they have mapped source and destination columns using ActiveX script which also has loop inside. I need to do same thing in SSIS...any body help me out please !!

Below give is the sample code of that ActiveX Script...please help me
====================
function Main()
{
// If true, row fails. Goes to false for each row
var bFailure = false;
// Contains value of condition string
var strValue ="";

// Only runs this routine once, and sets the conditions in the global variables for the remaining rows
if (DTSGlobalVariables("GotConditions") == false)
{
// Loop through all columns
for(var i=1;i< DTSSource.count;i++)
{
//Pass in field name to lookup for return of any conditions and store it in global var
strValue = DTSLookups("getConditions").Execute(DTSSource(i).Name);
DTSGlobalVariables(DTSSource(i).Name) = strValue;
}
// So this only happens once per import process
DTSGlobalVariables("GotConditions") = true;
}
// Loop through all columns
for(var i=1;i< DTSSource.count;i++)
{
// Global var is 0 if there are no conditions
if(!(DTSGlobalVariables(DTSSource(i).name)==0))
{
// Grab Condition(s) and eval them for true
// All conditions are OR'd with each other
var strCond = ""+DTSGlobalVariables(DTSSource(i).name)+"";
if(eval(strCond))
{
bFailure = true;
}
}
}
if(isNaN(DTSSource("MonFriOpenTime24"))){bFailure=true;}
if(isNaN(DTSSource("MonFriCloseTime24"))){bFailure=true;}
if(isNaN(DTSSource("SatOpenTime24"))){bFailure=true;}
if(isNaN(DTSSource("SatCloseTime24"))){bFailure=true;}
if(isNaN(DTSSource("SUN_O"))){bFailure=true;}
if(isNaN(DTSSource("SUN_C"))){bFailure=true;}

if (bFailure)
{
// Set the Changed field to 8, a failure or duplicate row
// so the import process knows not to transform it.
DTSDestination("Changed") = 8;
DTSDestination("InvalidDesc") = "Invalid Data" ;
}

DTSDestination("Post Date") = DTSSource("Post Date");
DTSDestination("Entity_ID_NK") = DTSSource("Entity ID");
DTSDestination("Division_ID_NK") = DTSSource("Division ID");
DTSDestination("DC_ID_NK") = DTSSource("DC ID");
DTSDestination("Store_No_nk") = DTSSource("Store no");
DTSDestination("DCID") = DTSSource("DCID");
DTSDestination("Division_Name") = DTSSource("Division Name");
DTSDestination("DC_Name") = DTSSource("DC Name");
DTSDestination("Store_Name") = DTSSource("STORE NAME");
DTSDestination("Business_Name") = DTSSource("Business Name");
DTSDestination("NAPA_Name") = DTSSource("NAPA NAME");
DTSDestination("Branch_Name") = DTSSource("Branch Name");
DTSDestination("Store_Type_Code") = DTSSource("Store Type Code");
DTSDestination("Store_Type_Name") = DTSSource("Store Type Name");
}
===============
Powichrowski Marek
Powichrowski Marek
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1169 Visits: 514
May be to use conditional split component from source and on this basis add destinations for each condition?
guptaopus
guptaopus
Old Hand
Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)Old Hand (394 reputation)

Group: General Forum Members
Points: 394 Visits: 244
But how do i use for loop in here as for loops are not allowed in data flow task?
Powichrowski Marek
Powichrowski Marek
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1169 Visits: 514
Please explain what you want to your package do. Sorry but it is difficult to analyze code Wink.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search