You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- 建测试表,并产生1000个ID
if object_id('tempdb..#r') is not null
drop table #r
create table #r
(
rn int identity(1,1) not null,
id bigint not null
)
set nocount on
declare @A int,@b int
select @A=1,@b=1000
while(@A<=@b)
begin
insert into #r(id)
select id=dbo.Fn_NextSnowId(rand())
select @A=@A+1
end
set nocount off
-- 结果有重复
select id,count(1)
from #r
group by id
having count(1)>1
The text was updated successfully, but these errors were encountered:
按 https://github.com/yitter/IdGenerator/blob/master/SQL/sqlserver.sql 的脚本创建函数, 测试产生有重复ID.
测试脚本如下:
-- 建测试表,并产生1000个ID
if object_id('tempdb..#r') is not null
drop table #r
create table #r
(
rn int identity(1,1) not null,
id bigint not null
)
set nocount on
declare @A int,@b int
select @A=1,@b=1000
while(@A<=@b)
begin
insert into #r(id)
select id=dbo.Fn_NextSnowId(rand())
select @A=@A+1
end
set nocount off
-- 结果有重复
select id,count(1)
from #r
group by id
having count(1)>1
The text was updated successfully, but these errors were encountered: