This is a discussion on random row within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi there. I need to fetch ONE random row from many. How can i get it? I try to ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| <anuke@bk.ru> wrote in message news:e23cb98a.0409290437.40d62abc@posting.google.c om... > Hi there. > I need to fetch ONE random row from many. How can i get it? I try to > execute "SELECT field.table FROM table ORDER by RAND()" no effect. > Thank you. See this code sample: http://vyaskn.tripod.com/code.htm#rand Or this is another possiblity, but MSSQL needs to scan the whole table, so it will be slow on large tables: select top 1 * from table order by newid() Simon |