May 15, 2011 at 9:25 am
How can I get the 8 characters that follow the characters 9^ in a field?
May 15, 2011 at 10:34 am
Is this what you are looking fo:
DECLARE @T VARCHAR(12)
SET @T = '9^1234567890'
SELECT CHARINDEX ( '^' ,@T,1) -- just so you understand what this performs
SELECT SUBSTRING(@T,CHARINDEX ( '^' ,@T,1)+1 , 8)
Result: 12345678
May 15, 2011 at 3:52 pm
Just in case you're looking for a solution to recognize both characters (code snippet heavily borrowed from Ron):
DECLARE @T VARCHAR(12)
SET @T = 'xy9^1234567890'
SELECT PATINDEX ( '%9^%' ,@T)
SELECT SUBSTRING(@T,PATINDEX ( '%9^%' ,@T)+2 , 8)
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply