You can achieve this by following this code.
In this code you can find 4 digit random number.
select cast(rand() * 10000 as int ) as RandNo If you want 6 digit random number then you use the following code snippet.select cast(rand() * 1000000 as int ) as RandNo