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 |
cidr
Posting Yak Master
207 Posts |
Posted - 2010-03-25 : 06:21:11
|
Hi there,I'd like to strip charactors to the left of a certain charactor. I can find out how to strip charactors to the right but this doesn't seem to apply in the same way.I simply want to strip anything to the left of the charactor £for example:SMD0023774 Bankton 26100 12/03/2010 £99.30I want to become:99.30Please can anyone help me hereThanks:) |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-25 : 06:24:32
|
[code]declare @str varchar(100)select @str = 'SMD0023774 Bankton 26100 12/03/2010 £99.30'select right(@str, charindex('£', reverse(@str)) - 1)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
cidr
Posting Yak Master
207 Posts |
Posted - 2010-03-25 : 06:54:49
|
Thank you khtan, life saver:) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-25 : 09:02:12
|
ordeclare @str varchar(100)select @str = 'SMD0023774 Bankton 26100 12/03/2010 £99.30'select substring(@str,charindex('£',@str)+1,len(@str))MadhivananFailing to plan is Planning to fail |
|
|
cidr
Posting Yak Master
207 Posts |
Posted - 2010-04-05 : 08:33:13
|
Thanks madhivanan, I'll keep both in mind:) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-05 : 09:55:32
|
Another variant:-declare @str varchar(100)select @str = 'SMD0023774 Bankton 26100 12/03/2010 £99.30'select stuff(@str,1,charindex('£',@str),'') ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|