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 |
|
nrsh_ram
Starting Member
3 Posts |
Posted - 2010-06-03 : 22:57:16
|
| hi to all...im newbie for SQL...here i have one row called Coordinator..Coordinator..value is PROJECT\a;PROJECT\b;PROJECT\c;PROJECT\e;PROJECT\dPROJECT\aPROJECT\a;PROJECT\bPROJECT\dPROJECT\ei want the data of Coordinator like thisPROJECT\ePROJECT\dPROJECT\ai dont want read the others..how to do it???plz help me.. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-06-04 : 01:17:53
|
| Try this:Declare @T Table(Tval varchar(5000))Insert into @TSelect 'PROJECT\a;PROJECT\b;PROJECT\c;PROJECT\e;PROJECT\d' union allSelect 'PROJECT\a' union allSelect 'PROJECT\a;PROJECT\b' union allSelect 'PROJECT\d' union allSelect 'PROJECT\e' select distinctCase When Charindex(';',Tval)>0 then substring(Tval,1, Charindex(';',Tval)-1) else Tval endFrom @TRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-04 : 03:46:29
|
| orselect distinct substring(Tval,1,patindex('%\[a-zA-Z]%',Tval)+1) from @TMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|