Selecting a random record from Table/View. Assuming the table name is Contact:
SELECT TOP 1 * FROM Contact ORDER BY NEWID()
GO
Tuesday, October 24, 2006
SQL: Select a random record
Subscribe to:
Posts (Atom)
First of all, the primary objective of this blog is for my own reference, as I am a very forgetful person, so, I need a way to document all findings, tips and tricks somewhere, which allows me access anytime anywhere. If you find any stuff here useful, you can go ahead and utilize it, and you are welcome to post your ideas and suggestions, I will be well appreciated them. But I will not answer to any queries regarding further elaboration on the topic I documented here.
Selecting a random record from Table/View. Assuming the table name is Contact:
SELECT TOP 1 * FROM Contact ORDER BY NEWID()
GO