Compare column value with a string inside Script task
Hi, I am trying to compare input column value with a string value inside a ScriptTransformation editor. C# code looks like below code block. If ( Row.inputcolumn1.ToString() != "N/A" ) {} else {} I am gettgin an Exception "reference not set to an instance of an object." -- Could you please help me to figure out how to compare any string value with the input column value? Code works fine is the column does have a value. Code fails with exception if the input is empty.
October 1st, 2012 8:49am

Is there a specific reason not to use the Conditional Split Task for such a requirement?Please vote as helpful or mark as answer, if it helps Cheers, Raunak | t: @raunakjhawar | My Blog
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 9:04am

I have to check more than 20 column in a row. That's why I wanted to avoid Conditional split and check the value of input column inside a script task.
October 1st, 2012 9:13am

Here you go. Ensure you choose Script Component as a Transformation. http://www.codeproject.com/Articles/193855/An-indespensible-SSIS-transformation-component-Scr http://www.sqlis.com/sqlis/post/The-Script-Component-as-a-Transformation.aspxPlease vote as helpful or mark as answer, if it helps Cheers, Raunak | t: @raunakjhawar | My Blog
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 9:22am

any null values for inputcolumn1? there is a boolean inputcolumn1_IsNull which you can use to check if it's filled. Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
October 1st, 2012 9:39am

I am not just looking for Null value. I want to check if any column has a specific value. Let's say I want to check if (Row.column1 == "TestString") . Is this possible?
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 9:43am

@Raunak J There is code inside one of the blog http://www.codeproject.com/Articles/193855/An-indespensible-SSIS-transformation-component-Scr // corresponding Result Buffer properties if (!string.IsNullOrEmpty(Row.Column1)) { ResultBuffer.ID = Row.Column0; ResultBuffer.CustomerName = str; } Above code does not compare if (Row.Colum1 =="Somevalue") -- I am having trouble to comare the value inside a if condition in a script task.
October 1st, 2012 10:01am

I am not just looking for Null value. I want to check if any column has a specific value. Let's say I want to check if (Row.column1 == "TestString") . Is this possible? Something like: if ((!Row.Column1_IsNull) && (Row.column1 == "TestString")) { } If (Not Row.Column1_IsNull) Ando (Row.column1 = "TestString") Then End If or do you want to do the same check for all columns?Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 10:18am

I am not just looking for Null value. I want to check if any column has a specific value. Let's say I want to check if (Row.column1 == "TestString") . Is this possible? Something like: if ((!Row.Column1_IsNull) && (Row.column1 == "TestString")) { } If (Not Row.Column1_IsNull) Ando (Row.column1 = "TestString") Then End If or do you want to do the same check for all columns?Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
October 1st, 2012 10:22am

Thank you. You answer was helpful.
Free Windows Admin Tool Kit Click here and download it now
October 4th, 2012 4:27am

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

Other recent topics Other recent topics