Most of the time, we need a functionality to generate random numbers in our application. SQL Server is offering a handy function to generate random numbers. Here is a small sample,
select rand()

Then, we need to multiply the function with 100.
SELECT 100*RAND()
The above query will fetch the recordds with decimal values which ranges from 0 to 100.

In case, If we need the value in Integer type. Then, we have to go for floor command which will remove the decimal part from the output.
SELECT floor(100*RAND())


Thanks and Regards,
Venkatesan Prabu .J
No comments:
Post a Comment