Andy Davies wrote: > Hi, > what is the nearest tsql for rat('/', cStr) and/or at('/', cStr,3) >
>From the help;
CHARINDEX Returns the starting position of the specified expression in a character string.
Syntax CHARINDEX ( expression1 , expression2 [ , start_location ] )
Arguments expression1
Is an expression containing the sequence of characters to be found. expression1 is an expression of the short character data type category.
expression2
Is an expression, usually a column searched for the specified sequence. expression2 is of the character string data type category.
start_location
Is the character position to start searching for expression1 in expression2. If start_location is not given, is a negative number, or is zero, the search starts at the beginning of expression2.
Real T-SQL code pulling out a - in a string and getting the text after that that is numeric only. CASE WHEN RIGHT(SUBSTRING(pa_page, CHARINDEX('-', pa_page)+1,15),1) <= '9' THEN SUBSTRING(pa_page, CHARINDEX('-', pa_page)+1,15) when right(rtrim(pa_page),1) between 'A' and 'Z' then ELSE LEFT(SUBSTRING(pa_page, CHARINDEX('-', pa_page)+1,15), LEN(SUBSTRING(pa_page, CHARINDEX('-', pa_page)+1,15))-1) END AS int) as 'values'
Stephen Russell S.R. & Associates Memphis, TN 38115
901.246-0159
©2004 Stephen the Cook |