This article mainly introduces the sql serial number acquisition code example. The example code is introduced in great detail in the article, which has a certain reference value for everyone's study or work. Friends in need can refer to it. It is often used to generate order numbers and other serial numbers. SQL Server implements serial numbers as follows: Table tb_b_Seq (serial number table): CREATE TABLE tb_b_Seq( Year int, -- year Month int, -- month Attr varchar(50), -- attribute Seq int -- serial number) Get the serial number through the stored procedure: create Proc GetSeq ( @attr varchar(50), @year int, @month int, @Return int output ) As set @Return=(select top 1 Seq from tb_b_Seq where Attr=@attr and MONTH=@month and YEAR=@year) if(@Return is null) begin set @Return=1 insert into FMDS_tb_b_Seq (Attr,Year,Month,Seq) values (@attr,@year,@month,@Return) end else begin set @Return=@Return+1 update FMDS_tb_b_Seq set Seq=@Return where Attr=@attr and MONTH=@month and YEAR=@year end test: declare @ret int exec GetSeq 'Contract',2017,10,@ret print @ret The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: jQuery implements shopping cart function
>>: Linux /etc/network/interfaces configuration interface method
Use JS to implement a random roll call system for...
In the previous article, we introduced the MySQL ...
Table of contents Scenario Analysis Development S...
Table of contents Asynchronous traversal Asynchro...
IIS7 Download the HTTP Rewrite module from Micros...
In previous blog posts, I have been focusing on so...
KDE Abbreviation for Kool Desktop Environment. A ...
<br />Most of the time when we talk about na...
Preface The three-column layout, as the name sugg...
For more exciting content, please visit https://g...
This article shares the installation and configur...
This article describes the mysql show operation w...
Preface: Recently, I encountered a management sys...
The mysql on the server is installed with version...