How to get random number in SQL

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