Welcome :Guest

Congratulations!!!

Top 5 Contributors of the Month
yasminpriya
Gaurav Pal
Ram
christianasteves

 Home >> Forum >> Sql Server >> Post New Question Subscribe to Forum
Posted Date: February 12, 2011     Points: 10

Hi

Yes. you can generate it..

SELECT ROUND(RAND() * 100,0)
GO

- The random number between 0 through 100

Cheers
www.sqlserverbuddy.blogspot.com

If not I then who, If not now then when
Author: shankey
Posted Date: February 14, 2011     Points: 5

hi,

Insert into RandomTable(randomnumber)
SELECT ROUND(RAND() * 1000,0)

Generates number from 0,1000 and insert in a table

Shankey
Author: Naresh
Posted Date: February 15, 2011     Points: 5

hi,,

The code for random no generation

// To generate the Random Number automatically.
public string ticketno()
{
StringBuilder builder = new StringBuilder("000");
builder.Append(randomno(1, 99999));
return builder.ToString();
}
private int randomno(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}

//Call the function in textbox.

this.TextBox1.Text = ticketno();

Thanks
Naresh
Author: Narayanan
Posted Date: July 20, 2011     Points: 20
Author: Ravi Ranjan Kumar
Posted Date: July 20, 2011     Points: 20

hey! have a go at given links where you can find a SQL script which will help you to generate Random Numbers
http://blog.sqlauthority.com/2007/04/29/sql-server-random-number-generator-script-sql-query/

Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com
Author: Ravi Ranjan Kumar
Posted Date: July 20, 2011     Points: 20

SET @Lower = 1000 - The lowest random number
SET @Upper = 9999 - The highest random number
SELECT @Random = Round(((@Upper - @Lower -1) * Rand() + @Lower), 0)
SELECT @Random

Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com