April 28, 2011 at 3:06 pm
Hi Guys,
Here is my source data
Address
c/o Joel Robuck
c/o Don Quick
c/o Sansone Group
c/o UCI
c/o Wendy Powers
C/O Goodwin Mgt
c/o Blake Magee Company
1101 S Cap of TX Hwy #F254
NULL
5910 Courtyard Dr #230
3701 Eagles Nest St.
NULL
2678 Henley Dr
And I want to map SOURCE.ADDRESS column to my TARGET.ADDR1 AND TARGET.ADDR2 if the source has c/o move to TARGET.ADDR2 otherwise stay in TARGET.ADDR1
Here is my expression that I am using in Derived column
ADDR1 = TRIM(SUBSTRING(Address,1,FINDSTRING(Address,"c/o",1)))
ADDR2 = UPPER(TRIM(SUBSTRING(Address,FINDSTRING(Address,”c/o",1),LEN(Address) - FINDSTRING(Address,"c/o",1) + 1)))
And I am getting nothing, Please advise me where I am wrong. Thanks for your help.
April 28, 2011 at 9:16 pm
Edit: posted advice won't work...
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
April 29, 2011 at 2:43 am
Is this what you are looking for ?
Declare @Address table (FullAddress varchar(500) , Address1 varchar(500), Address2 varchar(500))
insert into @Address ( FullAddress ) values ( 'c/o Joel Robuck')
insert into @Address ( FullAddress ) values ( 'c/o Don Quick')
insert into @Address ( FullAddress ) values ( 'c/o Sansone Group')
insert into @Address ( FullAddress ) values ( 'c/o UCI')
insert into @Address ( FullAddress ) values ( 'c/o Wendy Powers')
insert into @Address ( FullAddress ) values ( 'C/O Goodwin Mgt')
insert into @Address ( FullAddress ) values ( 'c/o Blake Magee Company')
insert into @Address ( FullAddress ) values ( '1101 S Cap of TX Hwy #F254')
insert into @Address ( FullAddress ) values ( NULL)
insert into @Address ( FullAddress ) values ( '5910 Courtyard Dr #230')
insert into @Address ( FullAddress ) values ( '3701 Eagles Nest St.')
insert into @Address ( FullAddress ) values ( NULL)
insert into @Address ( FullAddress ) values ( '2678 Henley Dr')
Select *
from @Address
update @Address
set Address1 = case when FullAddress like 'c/o%' then NULL else FullAddress end
, Address2 = FullAddress
Select *
from @Address
or is this what you are looking for ?
Declare @Address table
( FullAddress varchar(500)
, Address1 as (case when FullAddress like 'c/o%' then NULL
else FullAddress
end )
, Address2 as ( FullAddress )
)
insert into @Address ( FullAddress )
values ( 'c/o Joel Robuck' )
insert into @Address ( FullAddress )
values ( 'c/o Don Quick' )
insert into @Address ( FullAddress )
values ( 'c/o Sansone Group' )
insert into @Address ( FullAddress )
values ( 'c/o UCI' )
insert into @Address ( FullAddress )
values ( 'c/o Wendy Powers' )
insert into @Address ( FullAddress )
values ( 'C/O Goodwin Mgt' )
insert into @Address ( FullAddress )
values (
'c/o Blake Magee Company'
)
insert into @Address ( FullAddress )
values (
'1101 S Cap of TX Hwy #F254'
)
insert into @Address ( FullAddress )
values ( NULL )
insert into @Address ( FullAddress )
values (
'5910 Courtyard Dr #230'
)
insert into @Address ( FullAddress )
values (
'3701 Eagles Nest St.'
)
insert into @Address ( FullAddress )
values ( NULL )
insert into @Address ( FullAddress )
values ( '2678 Henley Dr' )
Select *
from @Address
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
April 29, 2011 at 9:09 am
Thanks for your reply, I have 60k records or more in my source file, Here is the solution that i just find out through ssis.
ADDR1 = UPPER(SUBSTRING(Address,1,3)) == "C/O" ? "" : Address
ADDR2 = UPPER(SUBSTRING(Address,1,3)) == "C/O" ? SUBSTRING(Address,5,50) : ""
If someone need more information i am more than happy to explain in more detail. Thanks.
April 29, 2011 at 10:17 am
Aaarch i overlooked the fact this thread is in the ssis forum, hence my nonsense answer to your Q.
Sorry for that.:blush:
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply