Question 18
You're designing a new query that will return all of the medical records from the patients table. This could run into millions of rows so you need to find a way to limit the results to include only the top 100 most recent records. What is the best way to achieve this?




Use TOP (or OFFSET and FETCH) instead of SET ROWCOUNT to limit the number of rows returned. These methods are preferred over using SET ROWCOUNT for the following reasons:

In SQL Server 2012, SET ROWCOUNT does not affect DELETE, INSERT, MERGE, and UPDATE statements.

As a part of a SELECT statement, the query optimizer can consider the value of expression in the TOP or FETCH clauses during query optimization. Because SET ROWCOUNT is used outside a statement that executes a query, its value cannot be considered in a query plan.


warning This is a sample question. You can start the practice exam by clicking the 'Start Practice Exam' link on the exam page.

Back to practice exam

 
Free practice exams are provided free of charge by Accelerated Ideas. Please respect our exams and do not reproduce our material or abuse the testing system. Thank you. Microsoft exams for MCPD, MCTS, MCP, MCSE, MCSA, MCAD, MCSD
Home 
Copyright © Accelerated Ideas 2005-2019
All rights reserved