Quantcast
Channel: Questions in topic: "ssis"
Viewing all articles
Browse latest Browse all 813

ssis card number check

$
0
0
Hi i've come up with the following code for a SSIS script component. My programming is pretty weak so could someone check this for me and let me know if there is a better way of doing it? It basically just looks for a regex in specified columns and nulls them if it finds anything... Thanks! This is to remove any card numbers that get stuck in phone or email columns in a dataflow... /* Microsoft SQL Server Integration Services Script Component * This is CozyRoc Script Component Plus Extended Script * 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; using System.Text.RegularExpressions; [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute] public class ScriptMain : UserComponent { public override void Input0_ProcessInputRow(Input0Buffer Row) { //Replace each \ with \\ so that C# doesn't treat \ as escape character //Pattern: Card matching Switch, Solo, Visa, MasterCard, Discover, American Express string sPattern = "^((67\\d{2})|(4\\d{3})|(5[1-5]\\d{2})|(6011))-?\\s?\\d{4}-?\\s?\\d{4}-?\\s?\\d{4}|3[4,7]\\d{13}$"; string BusinessEmail = Row.BusinessEmail; string BusinessPhone = Row.BusinessPhone; string HomePhone = Row.HomePhone; string MobilePhone = Row.MobilePhone; string PersonalEmail = Row.PersonalEmail; //Find any matches of the pattern in the string Match One = Regex.Match(BusinessEmail, sPattern, RegexOptions.IgnoreCase); Match Two = Regex.Match(BusinessPhone, sPattern, RegexOptions.IgnoreCase); Match Three = Regex.Match(HomePhone, sPattern, RegexOptions.IgnoreCase); Match Four = Regex.Match(MobilePhone, sPattern, RegexOptions.IgnoreCase); Match Five = Regex.Match(PersonalEmail, sPattern, RegexOptions.IgnoreCase); //If a match is found set field to null if (One.Success) Row.BusinessEmail = null; if (Two.Success) Row.BusinessPhone = null; if (Three.Success) Row.HomePhone = null; if (Four.Success) Row.MobilePhone = null; if (Five.Success) Row.PersonalEmail = null; } }

Viewing all articles
Browse latest Browse all 813

Trending Articles