Select n random rows from table In SqlServer
Sample Query
SELECT TOP n Column1,Column1
FROM tablename
ORDER BY NEWID()
But for SQL Function, modify as in below
ORDER BY (SELECT [NewID] FROM dbo.GetNewID)
SELECT TOP n Column1,Column1
FROM tablename
ORDER BY NEWID()
But for SQL Function, modify as in below
ORDER BY (SELECT [NewID] FROM dbo.GetNewID)
0 comments: