Possible Duplicate:
How do I generate random number for each row in a TSQL Select?
I am importing excel sheet into sql database, db table has the following columns:
srno | passportnumber|flightnumber
now when i import excel sheet the srno stays NULL after importing. Now i need this Srno column to be updated using sql query such that it has a random number or non-random serial number but it should have same srno value where the passport number is same i mean:
If passportnumber abc123 occurs 4 times each time the srno must have same value for eg :
srno | passportnumber|flightnumber
12 | ab32434 |AI-2011
13 | ab565235 |AI-2562
14 | ABC123 |AI-2025
14 | ABC123 |AI-2000
14 | ABC123 |AI-5623
15 |XYZ12334 |AI-5625
This will give serial numbers in order of passport. Modifying this to give truly random numbers based on a lookup dictionary preloaded with the randoms is trivial and I leave it as an exercise.