Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select only one row

Author  Topic 

BCJ
Starting Member

42 Posts

Posted - 2008-06-18 : 12:22:43
Hi,
how to restrict the query to select only one row .....thanks.

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-06-18 : 12:37:05
If you just want a single random row from a table you can do the following: select top 1 * from table
If you want to select a specific row from a table you will need to give more information for a good answer.
Go to Top of Page

BCJ
Starting Member

42 Posts

Posted - 2008-06-18 : 12:48:09
i just trying for a random record, thanks a lot
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-18 : 12:58:21
IF you want to get a random row, use

select top 1 * from table order by newid()


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -