Viewing 3 posts - 1 through 3 (of 3 total)
Try this modification of Jeff's suggestion. It accounts for the possibility of multiple alpha characters at the beginning of the string
DECLARE @SomeString CHAR(10);
SELECT @SomeString = 'XY00001250';
SELECT LEFT(@SomeString,CHARINDEX('0',@SomeString,1)-1)+RIGHT(RIGHT(@SomeString,LEN(@SomeString)-(CHARINDEX('0',@SomeString,1)))+0,9)
;
April 16, 2015 at 10:15 am
Elegant! Thanks, I learned something new today.
April 14, 2015 at 12:04 pm
LEFT('X000001250',1) + RIGHT('X000001250',CHARINDEX('0',REVERSE('X000001250'),2)-1) will work to remove the mid-string zeros for a value following the X + 9 digit format.
April 14, 2015 at 9:38 am
Viewing 3 posts - 1 through 3 (of 3 total)