SSIS Copy Column to Various Destinations based on Conditionhttp://forums.asp.net/t/1799906.aspx/1?SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionMon, 07 May 2012 16:34:29 -040017999064964581http://forums.asp.net/p/1799906/4964581.aspx/1?SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionSSIS Copy Column to Various Destinations based on Condition <p>Hi All,</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;In my current application I have a button to generate report based on certain filter criterion given on the page.</p> <p>To &nbsp;do this I have a SSIS package which simply converts data from SQL Server to Access (using Copy Column) task based on the filter set above.</p> <p>Now the requirement is to add a drop down which says <strong>&quot;select the format&quot;</strong> like .xls, .csv, .pdf, .mdb etc.</p> <p>If a user clicks on the button to generate reports now he is given the report in the format he selected.</p> <p>(I am not going with the SSRS approach because first of all I have huge data and secondly it doesn't allow us to save file in the access format - <strong>if I am not wrong)</strong></p> <p><b><br> </b>Please give me suggestion as to how I can do this with SSIS reports. I am not an SSIS expert so would require a detailed one.</p> <p></p> <p>Thanks,</p> <p><b><br> </b></p> 2012-05-04T02:00:01-04:004965818http://forums.asp.net/p/1799906/4965818.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Create a package variable, like @format or something that holds the value of the selected format.</p> <p>After your data source component, put a Conditional Split component that looks at the package variable and send the rows to the appropriate destination component.</p> <p>Look in the toolbox under destination compenents for your available options.&nbsp;&nbsp; You can use a flat file destination for csv, and obvious excel for excel.&nbsp;&nbsp; However, I don't believe you can export to .pdf using SSIS.&nbsp;&nbsp; The only reliable way I know to do that is with SSRS.</p> 2012-05-04T14:16:39-04:004968490http://forums.asp.net/p/1799906/4968490.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Hi TabAlleman,</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; That was a really helpful piece of advice and it works for me.</p> <p>However I also want to call this packages(which is doing the work I described above) through C# code.</p> <p>In my page I have some filter conditions based on which I am constructing the &quot;where&quot; clause of my data source and the tough job for me is to modify the where condition of the DataSource of the package from C# code before running the package.</p> <p>Please suggest me something on this.</p> 2012-05-07T07:35:17-04:004969121http://forums.asp.net/p/1799906/4969121.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Again, use package variables in your WHERE clause.&nbsp;&nbsp;&nbsp; This article shows you (near the end) how to set SSIS package variables from .net:</p> <p><a href="http://www.codeproject.com/Articles/28096/Excecute-SSIS-package-DTSX-from-ASP-Net">http://www.codeproject.com/Articles/28096/Excecute-SSIS-package-DTSX-from-ASP-Net</a></p> <p>&nbsp;</p> 2012-05-07T12:47:50-04:004969147http://forums.asp.net/p/1799906/4969147.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Is it possible for you to paste down the relevent section. Code Project is not opening up from my work place.</p> <p></p> <p>Thanks,</p> 2012-05-07T12:59:24-04:004969154http://forums.asp.net/p/1799906/4969154.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Sure.&nbsp;&nbsp; Hopefully it's not illegal.</p> <pre class="prettyprint">using Microsoft.SqlServer.Dts.Runtime; protected void btnExecute_Click(object sender, EventArgs e) { Application app = new Application(); Package package = null; try { string fileName = Server.MapPath(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName.ToString())); FileUpload1.PostedFile.SaveAs(fileName); //Load DTSX package = app.LoadPackage(@&amp;quot;D:\SSIS_ASP_NET\SSIS_ASP_NET_DEMO\SSIS_ASP_NET_DEMO\Package1.dtsx&amp;quot;, null); //Global Package Variable Variables vars = package.Variables; vars[&amp;quot;Business_ID&amp;quot;].Value = txtBusinessID.Text; vars[&amp;quot;Business_Name&amp;quot;].Value = txtBusinessName.Text; //Specify Excel Connection From DTSX Connection Manager package.Connections[&amp;quot;SourceConnectionExcel&amp;quot;].ConnectionString = &amp;quot;provider=Microsoft.Jet.OLEDB.4.0;data source=&amp;quot; &#43; fileName &#43; &amp;quot;;Extended Properties=Excel 8.0; &amp;quot;; //Execute DTSX. Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute(); } catch (Exception ex) { throw ex; } finally { package.Dispose(); package = null; } }</pre> <p></p> 2012-05-07T13:03:55-04:004969170http://forums.asp.net/p/1799906/4969170.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>TabAlleman,</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My query is to modify the &quot;Where&quot; clause of the &quot;OLE DB Source&quot; of my SSIS package from C#.</p> <p>E.g.</p> <p>Initially my query is</p> <p>Select Name, Age</p> <p>From Employee</p> <p>Where Name &lt;&gt; ''</p> <p><strong>Now from my C# code I want to modify the query to</strong></p> <p>Select Name, Age</p> <p>From Employee</p> <p>Where Name &lt;&gt; '' <strong>and Age &gt;= 30</strong></p> <p>(I want this because there can be many Where conditions based on the filter a user chooses in the page).</p> <p>I don't think the articles explains this.</p> 2012-05-07T13:10:41-04:004969198http://forums.asp.net/p/1799906/4969198.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>The part of the article I copied dealt with passing parameters to a package from .net.&nbsp;&nbsp;&nbsp;&nbsp; I assumed you already knew how to use parameters in your DB Source.</p> <p>So assuming you created a package variable called @WhereString and populated it with &quot; and Age &gt;= 30&quot;.</p> <p>Your Query in SSIS would be this:</p> <p>Select Name, Age From Employee Where Name &lt;&gt; '' ?</p> <p>The question mark is a place-holder for a variable.</p> <p>Then you go to the &quot;Parameter Mapping&quot; tab and map User::WhereString to parameter 0 (zero).</p> <p>That's it.</p> 2012-05-07T13:27:34-04:004969497http://forums.asp.net/p/1799906/4969497.aspx/1?Re+SSIS+Copy+Column+to+Various+Destinations+based+on+ConditionRe: SSIS Copy Column to Various Destinations based on Condition <p>Thanks for you help</p> 2012-05-07T16:34:29-04:00