Add the number of the last order1 (12-digit big data type)Create Function gettime (-- Definition variable) returns char (12) -- return type asbegin -- function body declare @ num decimal; -- growth number declare @ ID char (12 ); -- Return Value -- query the number of orders in the order table for the current day. Select @ num = count (*) from DBO. dd where convert (varchar (8), DBO. DD. ddsj, 112) = convert (varchar (8), getdate (), 112); -- if the current number is, incremental Int = 0001 if (@ num <= 0) begin set @ num = @ num + 1; Set @ ID = convert (varchar (8), getdate (), 112) + '000' + convert (varchar (4 ), @ num); End else -- if it is not zero, add the number of the last order to prevent repeated orders from begin select top 1 @ num = Ddid from DD order by Ddid DESC after deletion; set @ num = @ num + 1; Set @ ID = convert (varchar (12), @ num); end return @ ID; end; go
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