HiNot exactly sure what bit you mean to change. I want to change a string value to remove all character values and then return the number left over as a number value; got this bit ok. There is only a maximum of three digits that will be left over and no decimal places or anything like that.So looking at the full code below what do I have wrong?CREATE FUNCTION dbo.NumbersFromString (@str varchar(100)) --Value is originally a stringRETURNS NUMERIC AS BEGIN WHILE PATINDEX('%[^0-9]%', @str )> 0 -- Determines if there is any characters in the string, the number returned is where the first charcter in the string is identifiedset @str = REPLACE(@str, SUBSTRING(@str, PATINDEX('%[^0-9]%', @str),1),'') -- Replace values other than numbers with nothing.if LEN(@str) = 2 --Will also add code for value length = 1set @str = ('0' +@str) -- Add string '0' to existing string valueif @str = '' -- handles if string has no numbers in itset @str = '0'return CAST( SUBSTRING(@str, 1, 3) AS Numeric) -- Change type to numberENDThanksG