0

I have a table Lottery with columns:

  • Name
  • Ticket_number

I insert x number of names into this table, with the Ticket_number being NULL or 0. Then I want to loop over this table and randomize a number to update Ticket(Ticket_number) with that number.

I've read about cursors but don't really get it. I also saw something like "while SELECT * FROM Lottery exists, do stuff" but it requires you to delete rows, as it otherwise would infinite loop, no?

Anyone got any idea?

Cheers, hope it was somewhat clear.

Jordan
  • 1,390
  • 2
  • 9
  • 24
Mekaniker
  • 9
  • 2
  • 1
    Does this answer your question? [How do I generate a random number for each row in a T-SQL select?](https://stackoverflow.com/questions/1045138/how-do-i-generate-a-random-number-for-each-row-in-a-t-sql-select) – Martin Brown Dec 19 '22 at 19:15
  • Why to do this that way? Use your application to directly create correct insert commands having random numbers. No need to do this in SQL after the data has already been added. – Jonas Metzler Dec 19 '22 at 19:16

0 Answers0