January 26, 2010 at 8:37 am
Hi,
I have two expessions that I want to combine to be used in one column in derived column. How can I do this?
Please help.
Many Thanks
January 26, 2010 at 8:46 am
you probably want to show us the two expressions, and how you want them to be used together , i would think.
a crappy example is the ISNULL function is an expression. so something like
ISNULL(YourColumn,0.0) + ISNULL(YourColumn2,0.0) AS Total
is one example of using two expressions to make a signle derived value.
Lowell
January 26, 2010 at 8:54 am
Many Thanks for your response much appreciated.
These are my two expressions, how would I combine then?
REPLACE([Column_name],"-","")
(ISNULL([Column_name]) ? "" : [Column_name])
January 26, 2010 at 8:58 am
jyoti_bhatt (1/26/2010)
Many Thanks for your response much appreciated.These are my two expressions, how would I combine then?
REPLACE([Column_name],"-","")
(ISNULL([Column_name]) ? "" : [Column_name])
gotcha; you want to replace any value with isnull first, and then replace the dash; if the REPALCe function received Null it would crash with an error...so it would be like this:
REPLACE( (ISNULL([Column_name]) ? "" : [Column_name]) ,"-","")
Lowell
January 26, 2010 at 9:07 am
Wowww. u solved my problem in no time.
Thank you so much for this much appreciated, it worked.
Many Thanks.
January 27, 2010 at 4:33 am
How can I amend this expression to replace it to NULL rather than "" (a space)?
REPLACE([Column_name],"-","")
All help will be appreciated?
Many Thanks.
January 27, 2010 at 6:39 am
jyoti_bhatt (1/27/2010)
How can I amend this expression to replace it to NULL rather than "" (a space)?REPLACE([Column_name],"-","")
All help will be appreciated?
Many Thanks.
jyoti you would not replace part of a string with NULL; that's not what it's for.
I don't think you have a complete handle on how the REPLACE function works; you'd use replace like you were doing previously, to remove unwanted parts of strings with an empty string or space;
why don't you give us a specific example; what you have now is finding a hyphen and replacing it with an empty string..i might do that to a phone number for example, where i want to store the numbers, but not the hyphen.
show us a specific example of what you are wanting to do.
in tsql, string + null is null, so you'd erase the value instead of doing whatever you were thinking.
Lowell
January 27, 2010 at 8:17 am
Thanks for your reply.
I've used the below expression and that removes hyphen with NULL.
[column name] == "-" ? NULL(DT_WSTR,4) : [column name]
That worked for me.
Thanks anyways.
July 22, 2018 at 10:47 pm
okey thanks
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy