34 lines
665 B
Transact-SQL
34 lines
665 B
Transact-SQL
create table P_SystemSequenceTab(
|
|
|
|
-- ID列为自增列
|
|
SeqID int identity(1,1) primary key,
|
|
|
|
-- Sequence值
|
|
SeqVal varchar(1)
|
|
)
|
|
go
|
|
|
|
create procedure P_GetNewSeqVal
|
|
as
|
|
begin
|
|
-- 声明新Sequence值变量
|
|
declare @NewSeqValue int
|
|
|
|
-- 设置插入、删除操作后的条数显示取消
|
|
set NOCOUNT ON
|
|
|
|
-- 插入新值到表
|
|
insert into P_SystemSequenceTab (SeqVal) values ('a')
|
|
|
|
-- 设置新Sequence值为插入到表的标识列内的最后一个标识值
|
|
set @NewSeqValue = scope_identity()
|
|
|
|
-- 删除SeqT_0101001表(不显示被锁行)
|
|
delete from P_SystemSequenceTab WITH (READPAST)
|
|
|
|
-- 返回新Sequence值
|
|
return @NewSeqValue
|
|
|
|
end
|
|
|
|
go |