當(dāng)前位置:
首頁(yè) >
曾今的代码系列——获取当天最大流水号存储过程
發(fā)布時(shí)間:2025/7/25
42
豆豆
生活随笔
收集整理的這篇文章主要介紹了
曾今的代码系列——获取当天最大流水号存储过程
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
獲取當(dāng)天最大流水號(hào)存儲(chǔ)過(guò)程
alter procedure usp_getSelfSeqNo (@seqName nvarchar(32),@result int output ) as begin--判斷當(dāng)天是否存在該名字的流水號(hào)begin trandeclare @todayCount intselect @todayCount=COUNT(*) from T_DailySeqNo where SeqName=@seqName and DATEDIFF(DAY,SeqDate,GETDATE())=0if @todayCount<=0--不存在,則插入相應(yīng)的流水號(hào)begininsert into T_DailySeqNo (SeqName,SeqDate,CurValue)values(@seqName,convert(varchar(10),GETDATE(),20),0)--默認(rèn)初始值為0endelse--否則,更新+1beginupdate T_DailySeqNo set CurValue=CurValue+1where SeqName=@seqName and DATEDIFF(DAY,SeqDate,GETDATE())=0endselect @result=curvalue from T_DailySeqNo --獲取當(dāng)天的流水號(hào)where SeqName=@seqName and DATEDIFF(DAY,SeqDate,GETDATE())=0commit endd
轉(zhuǎn)載于:https://www.cnblogs.com/OceanEyes/archive/2012/09/07/2674445.html
總結(jié)
以上是生活随笔為你收集整理的曾今的代码系列——获取当天最大流水号存储过程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SQL Server 获取表或视图结构信
- 下一篇: 醒悟人生