Author |
Topic |
vasu4us
Posting Yak Master
102 Posts |
Posted - 2006-06-01 : 16:40:52
|
i know its a simple question but iam not able to fint the soluitoni have name and address columns which i have to break into Fname,Lname,street,city,state,zipcan anyone tell me the function or an examplethanks |
|
vasu4us
Posting Yak Master
102 Posts |
Posted - 2006-06-01 : 16:57:31
|
I tryed this way but iam getting wrong output.SELECT Right(AgencyName,CHARINDEX(' ', AgencyName)),CHARINDEX(' ', AgencyName),AgencyNameFROM dbo.Agenciesh Law 5 Eric Streich Law ttinger 7 Morgan and Pottinger verman Law 10 Silverman Law d Moore 7 Blatt, Hasenmiller, Leibsker, and Moore |
 |
|
vasu4us
Posting Yak Master
102 Posts |
Posted - 2006-06-01 : 17:45:44
|
solutionSELECT substring(EmpName,1,CHARINDEX(' ', EmpName)),substring(EmpName,CHARINDEX(' ', EmpName),LEN(EmpName)),CHARINDEX(' ', EmpName),EmpNameFROM dbo.TELE_CALL_LOG |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-06-02 : 06:03:40
|
Hi vasu4us,It looks like you need to get to grips with some string manipulation functions. Can you supply some sample data, so we can show you the kinds of things you can do to manipulate it... Thanks And I hope you're doing this to put the data into a normalised form, as in the link Madhivanan has supplied.Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
cmdr_skywalker
Posting Yak Master
159 Posts |
Posted - 2006-06-02 : 14:07:38
|
as a method of approach, either you have to separate first the names vs. address in the field or you can do it in one swoop. I suggest you extract first the names so that you can deal with different variant of names (LAST, FIRST or FIRST LAST etc.). By the way, if you're going to paste a sample data, include the column names and business constraints (or assumptions) in the data. TY.May the Almighty God bless us all! |
 |
|
X002548
Not Just a Number
15586 Posts |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-06-02 : 17:58:22
|
quote: Originally posted by X002548 There is no 100% solution
...unless he is dealing with a true comma-delimited data set and not the end-results of some poorly conceived free-text user entry form.If the dataset is consistently comma delimited, he might be able to parse it use DTS on import, or some similar solution. |
 |
|
cmdr_skywalker
Posting Yak Master
159 Posts |
Posted - 2006-06-02 : 20:04:03
|
Assume search for the first entry of the numeric character, assuming most of your data has a street number (if not, you have to handle them separately, either up to 3rd or 4th token, do some research about your data).declare @data VARCHAR(100)SET @data = 'John Doe 123 N street'SELECT CASE WHEN patindex('%[0-9]%', @data) > 0 THEN substring(@data, 1, patindex('%[0-9]%', @data)-1) ELSE 'do something else' ENDhere's a prev link:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=51476May the Almighty God bless us all! |
 |
|
|