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 |
Villanuev
Constraint Violating Yak Guru
478 Posts |
Posted - 2013-12-17 : 22:03:55
|
Hi Expert,I have a requirements to separate an string from the original string the reference is the -. my issue here is how could i get the last 3 chr. If there is a double L need to take out the one L. Your reply is very much appreciated. thanks.Sample DDLCreate table #sample(Location nvarchar(15))insert into #sample(Location) values('MARKET-L5') insert into #sample(Location) values('P-LL15') insert into #sample(Location) values('MARKET-L4') insert into #sample(Location) values('market-la') insert into #sample(Location) values('P-LL15')insert into #sample(Location) values('Market-L15') insert into #sample(Location) values('Market-L15') insert into #sample(Location) values('Market-RMA') insert into #sample(Location) values('P-LL16')ResultLocation --- ResultMarket-L15---L15Market-L3----L3MARKET-L5----L5P-LL15-------L15MARKET-L4----L4market-la----laP-LL15-------L15Market-L15---L15Market-L15---L15Market-RMA---RMAP-LL16 ---L16 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-17 : 22:07:04
|
[code]replace(right(Location, 3), '-', '')[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
Villanuev
Constraint Violating Yak Guru
478 Posts |
Posted - 2013-12-17 : 22:21:09
|
Thank you very much khtan. |
|
|
|
|
|