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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-06-14 : 07:18:18
|
| Thufail Ahmed writes "consider a table having column "id", values are like012-mark-china0116-peter-germany099-smith-Africa and so on....How to retrive only the middle part like mark,peter,smith and disply it in sorted form... using a single query..." |
|
|
gpl
Posting Yak Master
195 Posts |
|
|
JasonGoff
Posting Yak Master
158 Posts |
Posted - 2004-06-14 : 07:48:26
|
| select SUBSTRING(id,CHARINDEX('-',id)+1,LEN(id)-CHARINDEX('-',id,CHARINDEX('-',id)+1)-1) |
 |
|
|
JasonGoff
Posting Yak Master
158 Posts |
Posted - 2004-06-14 : 07:54:00
|
quote: Originally posted by gpl See this brilliant article http://www.sqlteam.com/item.asp?ItemID=15044Select PARSENAME(Replace(ID, '-', '.'),2) from <table>Graham
Now that is FAR more elegant than my approach. You learn something new every day. Thanks Graham ! |
 |
|
|
|
|
|
|
|