Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, June 27, 2013

How to get random records in Sybase IQ and SQL Server

Use Rand(PrimaryKey) function to get random number along with milliseconds as below


SELECT TOP 5 * FROM Employee Order by RAND( CONVERT(BIGINT,RAND(ID)*1000000000) - DATEPART( Millisecond   ,GETDATE()))

No comments:

Post a Comment