Generate custom code in Script component from .NET
Hi guys, I need to generate custom script in Script component of Dataflow task. For example, it's need to dynamically create output columns and set them programmatically values based on input columns. May be using CSharpCodeProvider? Do you have any klues? Thanks. looking for ASP.NET MVC work.
July 18th, 2011 9:21am

Dynamic columns is hard in SSIS. Can you give an example of what you want to accomplish?Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 4:33am

Is this what you are looking at on script task, the code is not omtimized but we can do that once your requirement is clear. In your case just assing the data set values from as an OBJECT varaible(like assing values from SQL source to a package level variable) in place of what i did with the XML, or just read the source directly form the Script task, if its XML as below DataSet dsXML = new DataSet(); DataTable dttableConfig = new DataTable(); dsXML.ReadXml( @\\Server\Filename.txt); dttableConfig = dsXML.Tables[ "Configuration"]; if (dttableConfig.Columns.Count == 1)//Check Column Count { Console.WriteLine("<do What you want to do>"); } else if(dttableConfig.Columns.Count == 2) { } Abhinav
July 19th, 2011 5:37am

Hi, Sample workflow is following: Input flat file contains [N] columns. Output columns count - [M]. M,N>0; DataFlow Task: Source Flat File (N Columns) ---> ScriptComponent (converting N columns into M columns) --> OLE DB Destination I have need to generate following code: /* Microsoft SQL Server Integration Services Script Component * Write scripts using Microsoft Visual C# 2008. * ScriptMain is the entry point class of the script.*/ 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 PreExecute() { base.PreExecute(); /* Add your code here for preprocessing or remove if not needed */ } public override void PostExecute() { base.PostExecute(); /* Add your code here for postprocessing or remove if not needed You can set read/write variables here, for example: Variables.MyIntVar = 100 */ } public override void Input0_ProcessInputRow(Input0Buffer Row) { Row.Oe1 = SomeFunction(Row.Id1,Row.Id2, ..Row.IdN); Row.Oe2 = SomeFunction(Row.Id1,Row.Id2, ..Row.IdN); ... Row.OeN = SomeFunction(Row.Id1,Row.Id2, ..Row.IdN); } And then put into component: Script script = new Script(importDataTask, "Generate Columns"); script.SetScript(AddBinaryCode, AddSourceCode); After it generate and execute package. looking for ASP.NET MVC work.
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 6:04am

Hi guys, I need to generate custom script in Script component of Dataflow task. For example, it's need to dynamically create output columns and set them programmatically values based on input columns. May be using CSharpCodeProvider? Do you have any klues? Thanks.looking for ASP.NET MVC work.
July 19th, 2011 11:20am

Hi, Using a Script component you will not be able to create the Columns Dynamically but you can set the values of the column using Row.Inputcolumn Name in your code.Rakesh M J Dont forget to mark it as Answered if found useful MCTS,MCITP,MCSS http://myspeakonbi.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2011 11:24am

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

Other recent topics Other recent topics