I have a Table . I want to select 15 Recods Randomly . if the Datbse doent have 15 record(If only 8 item then pick 8) .But as usal I want to pick 15 records.Please send me the query for it
First, this forum is specifically for SQL Server 2012, the coming version of SQL Server.
You can use this query to get 15 random rows from a table:
SELECT TOP 15 col1, col2, ....
FROM tbl
ORDER BY newid()
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se