I need you help...for a little problem. I have a java service that should access in a table and get a random row from table.
My table is simply: it contains only two cols:
"Id" INT IDENTITY(1,1) NOT NULL Primary Key
"Datas" Varchar(64) NOT NULL
Values Id is an progressive number, so you should think it could be enough to create a random number and get the row where id=randomic_number.
But I have lots of gap in table. So for example, a sample of table could be this:
ID Datas
1 Row1
2 Row2
3 Row3
8 Row4
10 Row5
25 Row6
639 Row7
Is there a very stylish way to get one row randomly? No condition must be...only random! I use sql srv 2000.
I would avoid to to...
select *
and then cycling the entire Resultset using a random number...because it can contain a very large number of rows....