我有下表
create table MBR_IDS
(
MBR_SLNO int identity(1,1),
MBR_ID int
)
GO
ALTER TABLE MBR_IDS
ADD CONSTRAINT UNIQUE_MBR_ID
UNIQUE NONCLUSTERED (MBR_ID)
和下面的存储过程来创建一个随机数
CREATE PROCEDURE USP_RANDOM_6
AS
BEGIN
DECLARE @chars NCHAR(36)
SET @chars = N'0123456789'
DECLARE @result NCHAR(6)
SET @result = SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
+ SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
+ SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
+ SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
+ SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
+ SUBSTRING(@chars, CAST((RAND() * LEN(@chars)) AS INT) + 1, 1)
SELECT @result
END
GO
当我通过存储过程插入一个值时:
declare @row int
set @row =1
while (@row <= 1000)
begin
insert into MBR_IDS
values(USP_RANDOM_6)
set @row = @row + 1
end
GO
我收到此错误: