Somthing like this ?? Create Function GetMax( @sNumber varchar(8000), @sSeperator char(1) = ',' )Returns floatAs Begin Declare @MaxNumber Float if isnull(@sSeperator,'') = '' Set @sSeperator = ',' Select @MaxNumber = Max(INROW) From ( Select NullIf(SubString(@sSeperator + @sNumber + @sSeperator , IDNos , CharIndex(@sSeperator , @sSeperator + @sNumber + @sSeperator , IDNos) - IDNos) , '') AS INROW FROM ( SELECT top 100 percent a.i+b.i+c.i+d.i as IDNos FROM ( Select 0 i union all Select 1 union all Select 2 union all Select 3 union all Select 4 union all Select 5 union all Select 6 Union All Select 7 union all Select 8 union all Select 9 union all Select 10 union all Select 11 union all Select 12 Union All Select 13 union all Select 14 union all Select 15 ) as a, ( Select 0 i union all Select 16 union all Select 32 union all Select 48 union all Select 64 union all Select 80 union all Select 96 Union All Select 112 union all Select 128 union all Select 144 union all Select 160 union all Select 176 union all Select 192 Union All Select 208 union all Select 224 union all Select 240 ) as b, ( Select 0 i union all Select 256 union all Select 512 union all Select 768 union all Select 1024 union all Select 1280 union all Select 1536 Union All Select 1792 union all Select 2048 union all Select 2304 union all Select 2560 union all Select 2816 union all Select 3072 Union All Select 3328 union all Select 3584 union all Select 3840 ) as c, ( Select 0 i union all Select 4096 ) as d order by 1 ) as f WHERE IDNos <= Len(@sSeperator + @sNumber + @sSeperator) AND SubString(@sSeperator + @sNumber + @sSeperator , IDNos - 1, 1) = @sSeperator AND CharIndex(@sSeperator , @sSeperator + @sNumber + @sSeperator , IDNos) - IDNos > 0 ) as f Where IsNumeric(InRow) =1 return @MaxNumber End GOSelect Dbo.GetMax('4,5,2,7,3,1',',')Chiraghttp://chirikworld.blogspot.com/