A buddy of mine pointed me to this blog post today. He had the need to pull a single random record from a database table. Traditionally, this has not been a completely trivial task, but not unattainable either. Well, the technique employed here is pretty cool. All you need to do is leverage the NewID() function in SQL Server 2000+.
SELECT TOP 1 * FROM tblSomeTable ORDER BY NEWID()
Pretty slick, eh?
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010R. Aaron Zupancic
E-mail