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 |
|
Clas
Starting Member
33 Posts |
Posted - 2009-12-02 : 05:07:01
|
| HiHow to split a string into 4 new fields and get the characters, except -1234-56-58-987 --> 1234 56 58 9875478-98-21-6587 --> 5478 98 21 65879875-75-11-55 --> 9875 75 11 55create table #temp(ID nvarchar(15),A int,B int,C int,D int)insert into #tempvalues ('1234-56-58-987',0,0,0,0),('5478-98-21-6587',0,0,0,0),('9875-75-11-55',0,0,0,0)UPDATE #temp ............Thanks in advance ! |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-02 : 05:14:24
|
| Try like thisselect parsename(replace('1234-56-58-987','-','.'),4), parsename(replace('1234-56-58-987','-','.'),3), parsename(replace('1234-56-58-987','-','.'),2), parsename(replace('1234-56-58-987','-','.'),1)Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
Clas
Starting Member
33 Posts |
Posted - 2009-12-02 : 05:22:23
|
| THANKS ! |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2009-12-02 : 05:51:11
|
| Also note that parsename works only for 4 parts.It wont work for 1234-56-58-987-0000.PBUH |
 |
|
|
|
|
|
|
|