Getordervalue Sort SQL Server

Source: Internet
Author: User

GO

-- =============================================
--Author: <Author,,rx.tang>
--Create Date: <create date,,>
--Description: <description,, get order value>
-- =============================================
CREATE FUNCTION [dbo]. [Getordervalue]
(
--Add The parameters for the function here
@v VARCHAR (50)
)
RETURNS VARCHAR (8000)
As
BEGIN

DECLARE @r VARCHAR (8000)
DECLARE @number VARCHAR (50)
DECLARE @splite INT
SET @r = "
IF (@v is null or LEN (@v) = 0)
BEGIN
RETURN '
END
while (1=1)
BEGIN
Set @splite = Patindex ('%[0-9]% ', @v)
IF (@splite > 0)
BEGIN
SET @r [email protected] + left (@v, @splite-1)
SET @v = Right (@v, LEN (@v)-@splite +1)
SET @splite = patindex ('%[^0-9]% ', @v)
IF (@splite > 0)
BEGIN
SET @number = Left (@v, @splite-1)
SET @r = @r + right (' 000000000000000000000000 ' + @number, 10)
SET @v = Right (@v, LEN (@v)-@splite +1)
END
ELSE
BEGIN
SET @r = @r + right (' 000000000000000000000000 ' + @v,10)
Break
END
END
ELSE
BEGIN
Break
END
END



RETURN @r

END

GO

Getordervalue Sort SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.