Sunday, June 1, 2014

Remove Last part


DECLARE @City TABLE ( CityName varchar(100));
INSERT @City VALUES
('1. Egypt'),
('1.1. Cairo'),
('1.1.21. New Cairo'),
('1.1.21.5. Alexandria')

SELECT CityName,
LEFT(CityName,PATINDEX('%[1-9]. [A-Za-z]%',CityName)-1) + SUBSTRING(CityName,PATINDEX('%[1-9]. [A-Za-z]%',CityName)+2 ,LEN(CityName))
FROM @City





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment