Description:
Here's a quick tutorial on how to generate random numbers in SQL Server.
00:05 - Basic RAND() usage
00:21 - Random number in specific range
00:36 - Random integer in specific range
00:52 - Issues with RAND()
Generate a random number between 0 and 1:
SELECT RAND()
Generate a random number between 50 and 100:
SELECT RAND() * (100 - 50) + 50
Just be aware that in certain scenarios RAND() isn't truly random, or it will return the same number. Here's my technique for selecting random row(s) from a SQL Server table: https://youtu.be/3LjGJqg8mEI
RAND() reference: https://docs.microsoft.com/en-us/sql/t-sql/functions/rand-transact-sql
If you found this video leave a LIKE and SUBSCRIBE for more coding videos.
Check out my SQL Programming playlist for more tutorials: https://www.youtube.com/playlist?list=PLVQbq9wVileaQK3hur907sqqJZwgmjpoT
Stock footage credit: https://www.pexels.com/@rudonni
Share this link via
Or copy link























