have values 'abcde:fg' and 'abcde' i need to remove the ':fg' from the first value. Using SQL so far i have used the substring function to remove the '12:' from the value '12:abcde:fg'. having an issue with the :fg' part now. Any help is appreciated. thanks! however some values are 'AA:12:abcde:fg' how would i edit this script to still return the 'abcde' part of this string?
Give this a go. Haven't tested it but should be something like that:
DECLARE @string varchar(50) = '12:abcde:fg' SELECT SUBSTRING(@string, charindex(':',@string) + 1, charindex(':',@string,charindex(':',@string) + 1) - (charindex(':',@string) + 1))