CMChalcraft
asked on
Splitting a field in SQL
I have this string BPL-TS02/COMPANY-NAME\jsmi th.
I do I just extract the jsmith element? I cannot just use RIGHT as the name will vary in the number of characters.
I do I just extract the jsmith element? I cannot just use RIGHT as the name will vary in the number of characters.
What you need as the output from the string, I shall write it for you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please try this
--
DECLARE @ AS VARCHAR(1000) = 'BPL-TS02/COMPANY-NAME\jsmith'
SELECT SUBSTRING(@,CHARINDEX('\',@,0)+1,(DATALENGTH(@)+1)-CHARINDEX('\',@,0))
--
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are good solutions here, so should be closed by accepting the Experts comments.
Pawan, even your comment is right, ste5an's and Scott's also are.