ssis script general question
Please assume I know almost nothing about SSIS....sorry newb question: I have a script SOURCE DB>SCRIPT>DEST DB public override void Input0_ProcessInputRow(Input0Buffer Row) { Row.newName = GetName(Row.oldName); } public string GetName(string oldName) { string strDate = Date.Now().ToString(); string strName = strDate+oldName return strName; } If I have 50 000 rows in my table can I speed up my table by making strDate a global or is each Row a new start to the script? cs
May 29th, 2012 3:32pm

Wouldn't hurt to make it global, especially if you want all of the rows to have the same datetime on them. Date.Now().ToString(); is going to give you a datatime unless you provide a format for the ToStringChuck Pedretti | Magenic North Region | magenic.com
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2012 3:37pm

Why would you need to rename a row column name?Arthur My Blog
May 29th, 2012 3:38pm

Why would you need to rename a row column name? Arthur My Blog Hes not. He is taking the value of a column called OldName and prepending a date to it to populate a column called newNameChuck Pedretti | Magenic North Region | magenic.com
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2012 3:39pm

For what you are doing you could just use a derived column block and skip the scripting alltogether - unless you are doing something more complex that you are not showing. Expression like this would work (DT_WSTR,4)YEAR(GETDATE()) + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2) + RIGHT("0" + (DT_WSTR,2)DAY( GETDATE()), 2) + OldName Chuck Pedretti | Magenic North Region | magenic.com
May 29th, 2012 3:41pm

Yes, I am doing something more complicated or different. I am running a few Regex's (so the dateTime thing is not important). My concern if for speed.
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2012 4:31pm

You may want to use the SSIS built in System dates System::StartTime/System::ContainerStartTime in a Derived Column Transformation to assign to the Row.newName that is a non blocking component thus achieving top speedsArthur My Blog
May 29th, 2012 4:43pm

The script as you have it is pretty much as fast as it's going to get. If you unwind the script wrappers, you'll see that SSIS' call to your ProcessInputRow is nested inside some other methods, inside a loop. You can unwind that so there aren't as many stacks pushed and popped, but that's not going to get you much of an increase in performance. If you're doing some Regex work, that's likely the slow part of this equation - not the decoration of method calls and how nested they are. Try to optimize the guts of what you're doing with the Regex, because that can be slow. Secondly, what does "slow" mean? What's the limiting resource here? CPU? Memory? Is a single core getting pinned? If it's a single-core problem (your data flow pins a single core but you have more cores unused), then you can parallelize the data flow. Use a Conditional Split to (try to) equally divide your flow, and copy and paste the script component to handle multiple flows. Use a Union All or Merge to join the flows back together. Talk to me now on
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2012 6:30pm

You need to take note that calling Date.Now.ToString() returns a timestamp meaning the value will change everytime you call it. Is this what you want? If you're aiming for same value althroughout the process you may want to declare it as a Class Level Variable and you can also make it static like: static string mDate = DateTime.Now.ToString("yyyyMMddhhmmsstt"); public override void Input0_ProcessInputRow(Input0Buffer Row) { Row.newName = mDate + oldName; } Randy Aldrich Paulo MCTS(BizTalk 2010/2006,WCF NET4.0), MCPD | My Blog BizTalk Message Archiving - SQL and File Automating/Silent Installation of BizTalk Deployment Framework using Powershell > Sending IDOCs using SSIS
May 30th, 2012 3:28am

thanks. I was thinking the local declaration string strDate = "myLocalString" being replaced by private string strDate = "myGlobalString" would make the code faster but since it does not matter I will leave as a local. I don't care for speed now. I just want to do it right so if I need it later I can use it. thanks.
Free Windows Admin Tool Kit Click here and download it now
May 30th, 2012 8:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics