I am using MSSQL 2005 for a query, say:
SELECT * from Emp UNION ALL SELECT * from Emp2;
And I want to limit the final result to 10 rows.
IF I had only the Emp table, I would say
SELECT TOP 10 * from Emp;
But since I have 2 tables now, I can’t say SELECT TOP * on any of them, neither I can use LIMIT 10 in the end.
Do you have any suggestion?
However, I would suggest maybe you order the results so that you don’t just get top 10 results from first union result. So something like this maybe: