Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
My Document No is 'CY/EV/13-14/00014'
and i want output like 'EV/00014'
Posted

Read here how you may use RegEx for data extraction...
http://msdn.microsoft.com/en-us/magazine/cc163473.aspx[^]
 
Share this answer
 
plz try this code

SQL
CREATE TABLE #TempTable(
docNo varchar(500))
INSERT INTO #TempTable (docNo)
VALUES ('CY/EV/13-14/00014')
SELECT * FROM #TempTable


Select SUBSTRING( docNo, charindex('/',docNo, 1)+1,2) + Substring(docNo,LEN(docNo) - Charindex('/',Reverse(docNo))+1,LEN(docNo)) as docNo
FROM #TempTable
 
Share this answer
 
Use the CHARINDEX function to find the index of the '/' character, extract the characters in-between and finally concatenate the strings as required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900