Page 1 of 1

setNull() output in Char(1) data type

Posted: Mon Dec 20, 2010 12:21 am
by Amar_nath
Hello All,
I am working on IIS 8.1 and source & target database is MS SQL server.

I have one flag in target table with data type char(1). I want to set value NULL when it is not Y or N. I am achieving using -

If ( monitoring_flag != 'Y' and monitoring_flag != 'N')
Then SetNull()
Else monitoring_flag

When I check in database I can see empty cell for this flag and not NULL.

:?: What should be done to achive the same?

Thanks & Regards.

Posted: Mon Dec 20, 2010 12:22 am
by Amar_nath
Sorry the logic in transformer is as below -

If ( monitoring_flag <> 'Y' and monitoring_flag <> 'N')
Then SetNull()
else monitoring_flag

Re: setNull() output in Char(1) data type

Posted: Mon Dec 20, 2010 3:45 am
by manoj_23sakthi
Hi,
you can obtain this using this
If ( monitoring_flag <> 'Y' or monitoring_flag <> 'N')
Then SetNull()
else monitoring_flag

Posted: Mon Dec 20, 2010 4:38 am
by Sreenivasulu
Use OR instead of AND

Regards
Sreeni

Posted: Mon Dec 20, 2010 5:06 am
by Amar_nath
Hi All,

Something which is unclear to me.. bit strange ..

If (len(trim(monitoring_flag)) = 0 or Seq(monitoring_flag) = 0)
Then SetNull()
else monitoring_flag

this works fine .. gives NULL in output
but when I check

If IsNull(monitoring_flag)
Then SetNull()
else monitoring_flag

it gives spce in that flag .. i.e. ASCII 32.. I donno why .. any suggestions ?

Try this one

Posted: Thu Dec 23, 2010 2:55 am
by veerabusani185512
If ( trim(nulltoempty(monitoring_flag)) ='Y' or trim(nulltoempty(monitoring_flag)) = 'N')
Then monitoring_flag else setnull()