February 26, 2011 at 8:43 pm
Hi Guys,
I have question regarding Trim function,
Here is my requirement,
Address = ADDRESS1+ADDRESS2+ADDRESS3
I want to trim if there is no Address1 or Address3
I know i can use Ltrim & Rtrim function, Could you please anyone can help me how i can use trim function in TSql and SSIS. Thanks in advance.
February 26, 2011 at 10:06 pm
rocky_498 (2/26/2011)
Hi Guys,I have question regarding Trim function,
Here is my requirement,
Address = ADDRESS1+ADDRESS2+ADDRESS3
I want to trim if there is no Address1 or Address3
I know i can use Ltrim & Rtrim function, Could you please anyone can help me how i can use trim function in TSql and SSIS. Thanks in advance.
Address = RTRIM(LTRIM(ADDRESS1+ADDRESS2+ADDRESS3))
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
February 27, 2011 at 12:34 pm
rocky_498 (2/26/2011)
Hi Guys,I have question regarding Trim function,
Here is my requirement,
Address = ADDRESS1+ADDRESS2+ADDRESS3
I want to trim if there is no Address1 or Address3
I know i can use Ltrim & Rtrim function, Could you please anyone can help me how i can use trim function in TSql and SSIS. Thanks in advance.
If the addresses are VARCHAR and are NULL when missing, then the following will work just fine...
SELECT RTRIM(ISNULL(Address1 + ' ','') + ISNULL(Address2 + ' ','') + ISNULL(Address3,''))
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply