解决思路:计算每位的权重,得到序号完整的权重值,使用权重值进行排序!

创建sql 函数如下:

ALTER FUNCTION [dbo].[SequenceToOrderNum] ( @Sequence VARCHAR() )
RETURNS INT
    BEGIN
        DECLARE @Count INT
        DECLARE @OrderNum INT
        SET @Count =  --根据需求改变
        SET @OrderNum =
        WHILE CHARINDEX(
            BEGIN
                SET @OrderNum = @OrderNum
                    + CAST(SUBSTRING(@Sequence, , CHARINDEX('.', @Sequence)) AS NUMERIC)
                    * POWER(, @Count)--根据需求改变

                SET @Sequence = SUBSTRING(@Sequence,
                                          CHARINDEX(,
                                          LEN(@Sequence))

                SET @Count = @Count -
            END

        SET @OrderNum = @OrderNum + CAST(@Sequence AS NUMERIC) * POWER(,---根据需求改变
                                                              @Count)
        RETURN @OrderNum

    END

 --结果: =>
05-07 15:41