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 |
|
AsimKhaliq
Yak Posting Veteran
94 Posts |
Posted - 2004-03-18 : 11:50:01
|
| HiI want to break my filed data into two fieldCreate table table1(Name varchar(25),Address varchar(50))insert into values('Abc dcs','1234 keel')insert into values('John Peep','123 keel')insert into values('JPeep','124 keel')insert into values(Null,'1234 keel')So what i want to do is break name field into lastname and first name and put my data into another table.but if there isn't any space b/wthe name fild then it should be emptySo my new table will be like thisLastName|firstName|addressABC|Dec|1234 keelJohn|Peep|123 keelJohnP||124 keel||1234 keelThanks |
|
|
SQLCode
Posting Yak Master
143 Posts |
Posted - 2004-03-18 : 12:07:43
|
| This might helphttp://vyaskn.tripod.com/code.htm#split |
 |
|
|
AsimKhaliq
Yak Posting Veteran
94 Posts |
Posted - 2004-03-18 : 12:22:43
|
| ThnksBut this doesn't help me atall, what I want is just to split my name field into 2 columslike Jon PeepFirstname= johnLastname=PeepI need a funtion to split or any funtion from which I can search space and splitThnx |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-03-18 : 12:35:01
|
| Have you looked at CHARINDEX to determine where the space is? You could then use that value to break them up using SUBSTRING.Tara |
 |
|
|
|
|
|