SQL Server Articles

Submit Article
Home » Articles » SQL Server » Math FunctionsRSS Feeds

RAND Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4536

This article explains RAND function of sql server with examples.

RAND returns random float value from 0 through 1.  

Syntax of RAND Function :


seed is an integer value. If you don't specify seed value then sql server takes random seed value and returns random float value for that seed value. But if you specify seed value then the result returned is always same value.
Return type of RAND is float data type.

Examples of RAND Function :

Example 1 : Use of RAND function in select clause



Above example returns different value each time when you execute above query because each time sql takes different input value for RAND function.

Example 2 : Use of RAND function in select clause



Above example always returns same result for specified input value for RAND function.


Didn't find what you were looking for? Find more on RAND Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of RAND Function is from United States.
View All Articles

Related Articles and Code:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!