How can I generate a unique random number at each row of record?
I'm using SQL Server 2000. I'd like to generate random number without repetition at each row. However, my code is not working. I tried many times but I cannot fix the repetition problem. My code as below: I used "case" to handle duplicate number but it does not work. Can anyone help me? DECLARE @index INT ,@ran_no INT ,@counter INT ,@i INT SET @i = 1 WHILE @i <= 18 BEGIN SELECT @index = count(basket_seq) FROM dbo.test WHERE basket_seq = @i AND flag = 'left' BEGIN UPDATE dbo.test SET @ran_no = convert(INT, 1 + @index * RAND(CHECKSUM(NEWID()))) ,@ran_no = ( CASE WHEN convert(INT, 1 + @index * RA
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.