Friday, March 9, 2012

Expression help needed

I use the following expression to convert zero length character strings to and int value of 0 :

comno_type == "" ? "0" : comno_type

however, some of the data I'm trying to copy contains 1 character long blank strings or " " to be precise. Can I get the above expression to handle both the zero and 1 char strings at the same time. I've tried things like:

comno_type == "", " " ? "0" : comno_type

but this is a syntax error.

Would I need to do separate expressions to handle each type of string? and if so, how do I get them into the same destination column?

Thanks

Try

(comno_type == "" || comno_type == " ") ? "0" : comno_type

Greg.
|||

Cheers , that's done the trick.

can't see the wood for the trees sometimes me, I really shouldv'e been able to work that out, is there a syntax guide for the expressions or is it in with Books Online?

|||

Yes and yes, ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/extran9/html/8b80403f-6d45-4001-8b12-25a933c663a2.htm

or

Integration Services Expression Reference
(http://msdn2.microsoft.com/en-us/library/8b80403f-6d45-4001-8b12-25a933c663a2.aspx)

|||

TRIM(comno_type) == "" ? "0" : comno_type

No comments:

Post a Comment