OLEDB Command object is not validating Col =NULL in where condition (column we are mapping in the column mapping table)
Hi I have Update command in OLEDB Command (Data flow tranformation) update dbo_xyz.RefCopy set updatedby = ?, updatedon =?, currentrecordind = ? where KeyId1=? AND KeyId2= ? and StgClaimTextRefID=? and updatedby is null i have mapped the 6 parameter in the colum mapping the problem here is whenever the KeyID2 is getting NULL at runtime its not working i mean update dbo_xyz.RefCopy set updatedby = 'System', updatedon =getdate(), currentrecordind = 0 where KeyId1=1 AND KeyId2= NULL and StgClaimTextRefID=123 and updatedby is null the above updated is not working but update dbo_xyz.RefCopy set updatedby = 'System', updatedon =getdate(), currentrecordind = 0 where KeyId1=1 AND KeyId2 IS NULL and StgClaimTextRefID=123 and updatedby is null is working KeyId2= NULL -is not updating (1st query) KeyId2 IS NULL - is working (2nd query)ilikemicrosoft
May 31st, 2012 5:04am

Change condition to where (KeyId1=1 AND (KeyId2 IS NULL OR KeyId2= ?) and StgClaimTextRefID=123 Abhinav
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 5:19am

So, since the 2nd update is working, what is the problem?
May 31st, 2012 5:19am

Change condition to where (KeyId1=1 AND (KeyId2= NULL OR KeyId2= ?) and StgClaimTextRefID=123 Abhinav
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 5:25am

the problem is coming because you cannot compare null in the db with the coming from your source. what i can suggest u is to replace nulls in ur source or staging as 'na' (here if u can make keyid2 as 'na ' )and use the following.using this u can directly map with your columns update dbo_xyz.RefCopy set updatedby = ?, updatedon =?, currentrecordind = ? where KeyId1=? AND isnull(KeyId2,'na')= ? and StgClaimTextRefID=? and updatedby is null
May 31st, 2012 5:36am

you have to use isnull(KeyId2,'')='' isnull function can solve your problem.Regards, nishantcomp2512 Please mark posts as answered where appropriate
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2012 9:45am

Hi surendiran, IS NULL is not = NULL, to determine if an expression is NULL, use IS NULL or IS NOT NULL rather than comparison operators (such as = or !=). Comparison operators return UNKNOWN if either or both arguments are NULL. For more information about it, please refer to: http://msdn.microsoft.com/en-us/library/aa933227(v=sql.80).aspx http://sqlblog.com/blogs/hugo_kornelis/archive/2007/09/30/what-if-null-if-null-is-null-null-null-is-null.aspx Thanks, Eileen
June 4th, 2012 4:23am

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

Other recent topics Other recent topics