1

I have a table named Orders and a column in that table named OrderID. Initially the value for the OrderID is given manually, but now I have to change those values to random of numbers between 100 and 999.

I have nearly 600 rows... When I tried the following code it assigned a single random number to all the orders. Kindly help me on this, and explain me what's the easy and right way to solve this.

UPDATE Orders
 SET OrderID= RAND()*(999-100)
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331

1 Answers1

0

Try like this:

UPDATE Orders 
SET OrderID = ABS(Checksum(NewID()) % 900) + 100

SQL FIDDLE DEMO

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331