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 |
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2010-07-28 : 09:07:00
|
| i need a query to trim the column value as belowQUERYselect Country from WorldTableRESULTCountry Old-India_0001Country-Japan_0002Country New-China_0003Need QUERYselect substring(Country,5 ,200) from WorldTableExpected RESULTIndia_0001Japan_0002China_0003The trim should be based on -the 5 should be replcaed dynaimcally by -i am unable to form the substringKindly provide me the queryTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
kashyap_sql
Posting Yak Master
174 Posts |
Posted - 2010-07-28 : 09:08:45
|
| give clarity to your postWith RegardsKashyap M |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-28 : 09:13:27
|
select stuff(Country,1,patindex('%-%',Country),'') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-28 : 09:22:23
|
Have you tried my solution? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2010-07-28 : 09:24:05
|
| Thanks webfred !THANKSSHANMUGARAJnshanmugaraj@gmail.com |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-28 : 09:26:34
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-07-28 : 09:29:22
|
| orselect substring(Country,patindex('%-%',Country)+1,len(Country))MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|