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 |
jodders
Starting Member
41 Posts |
Posted - 2013-08-08 : 05:28:12
|
Morning all,I have set of data which has starts with the later "ABC\Bert" or "XYZ\Ernie" and would like to trim it so that anything after the "\" shows in my sql statement. I was thinking of doing a left trim but annoying, there are results in my table that already have data with out the "ABC\" or "XYZ\" in . Any advice on how to make these changes?Cheers |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-08 : 05:44:32
|
DECLARE @str VARCHAR(30) = 'ABC\Bert'SELECT SUBSTRING( @str, CHARINDEX( '\', @str)+1, 30)--Chandu |
|
|
jodders
Starting Member
41 Posts |
Posted - 2013-08-08 : 05:53:16
|
Thanks chandu, works great |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-08-08 : 06:17:08
|
[code]SELECT STUFF(@str,1, CHARINDEX( '\', @str),'')[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-12 : 01:20:55
|
quote: Originally posted by jodders Thanks chandu, works great
Welcome--Chandu |
|
|
|
|
|