.net - Add a derived column to a table via C# script in SSIS -
I want to add a column to an existing table with the calculated using a hash function (MD5) and results. I am using a script function in SSIS to write a small script # I here is my script: My SSIS package looks like this:
using the system; Using System.Data; Using Microsoft.SqlServer.Dts.Pipeline.Wrapper; Using Microsoft.SqlServer.Dts.Runtime.Wrapper; Using System.Security.Cryptography; Using System.Text; Using System.Windows.Forms; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain: UserComponent {public override void PreExecute () {base.PreExecute (); / * * Add your code here * / / Public override zero PostExecute () {base.PostExecute (); / * Add your code here * /} public override void Input0_ProcessInputRow (Input0Buffer row) {/ * using your code * / Add here (MD5 md5Hash = MD5.Create ()) {string hash = GetMd5Hash (md5Hash, line ); MessageBox.Show (hash); }} Static string GetMd5Hash (MD5 md5Hash, Input0Buffer input) {// input string to calculate convert a byte array and hash byte [] data = md5Hash.ComputeHash (encoding. UTF8.GetBytes (input.ToString ()) ); To collect // bytes, create a new string builder // create a string. Stringbuilder sBuilder = new stringbilder (); // Format as loop / / and every hexadecimal string through each byte of hash data. For (int i = 0; i & lt; data; height; i ++) {sBuilder.Append (data [i]. Ostring ("x2"); } // return hexadecimal string return sbuilder.ToString (); }}
I'm in line to grab the table from the database from just one row. I want to havehes in all the columns, create another column and archive the result of hashes. I am able to generate a hash, but I do not know how to add columns to the result set and enter the values of hash in that column. Any help would be appreciated. . Thank you
As to assign column in C # you look like asked in response to your code billinkc are:
public override void Input0_ProcessInputRow (Input0Buffer row) {/ * use your code here * / (MD5 md5Hash = MD5.Create ()) {// string hash = GetMd5Hash (MD5 hash, cry); Ro.mayutputakumol = gatemd5 hash (md5 hash, cry); //MessageBox.Show (hash); }}
Comments
Post a Comment