Generate serial Number

Source: Internet
Author: User

/* AUTHOR:YUCL

Createdate:2015-09-28

Functionname:functaskno

Remark:description: Get Task number

version:v1.0 * *

ALTER FUNCTION Functaskno

(@TaskNO varchar (30))

Returns varchar (a) BEGIN

DECLARE @TaskNewNo varchar (30)

DECLARE @TaskMaxNo varchar (30)

-Get the final training mission released today

SELECT @TaskMaxNo =max (taskno) from Traintaskinfo

where Convert (varchar), createtime,120) =convert (varchar), GETDATE (), 120)

DECLARE @CurDate varchar (16)

SELECT @CurDate =replace (replace (CONVERT (varchar), GETDATE (), 120), '-', '), ': ', ', ')

--a release mission today

IF (Len (@TaskMaxNo) <> ")

Begin

Select @TaskNewNo =substring (@TaskMaxNo, LEN (@TaskMaxNo) -4,4)

Select @TaskNewNo =right (CONVERT (int, @TaskNewNo) +1,4)

End

--No tasks released today

ElSE

BEGIN

Select @TaskNewNo =right (' 1 ', 4)

END

Select @[email Protected][email protected]

Return @TaskNewNo

END

GO

Generate serial Number

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.