Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hoffmann
Starting Member
6 Posts |
Posted - 2009-10-06 : 11:04:45
|
hi folks, sorry to bother you again, but I'm really stuck at this point...I have to import an address but I need to break the number from the street.e.g: '5th avenue, 555' would end up as '5th avenue','555'.I've searched a lot on the web and tried to use Substring, but I still didn't get it to work properly. Can somebody help me? Or gimme the link to where I could get help?Thank you! |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-06 : 11:32:21
|
First have a look at your data please.I'm sure that '5th avenue, 555' is the most practicable version but which data combinations are also in your table.Is there a way to tell us a condition on how to split the data so it fits to (nearly) all data? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
X002548
Not Just a Number
15586 Posts |
|
Hoffmann
Starting Member
6 Posts |
Posted - 2009-10-06 : 13:02:46
|
yeah, every number is after a " , "...always. I think it's pretty easy but I've not figured it out yet Oo |
 |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2009-10-06 : 13:30:30
|
[code]DECLARE @x varchar(255)SET @x = '5th avenue, 555'SELECT '"' + SUBSTRING(@x,1,CHARINDEX(',', @x)-1) + '"' AS Street , '"' + SUBSTRING(@x,CHARINDEX(',', @x) + 2, LEN(@x) - CHARINDEX(',', @x) + 1) + '"' AS [Date?] [/code]Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-07 : 02:13:08
|
If there is always a single commaDECLARE @x varchar(255)SET @x = '5th avenue, 555'select PARSENAME(replace(@x,',','.'),2) , PARSENAME(replace(@x,',','.'),1)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|