SQLConfiguration SQLConfiguration

Queries, Cursors, Views  «Prev  Next»
Lesson 2Queries, Cursors, and Views Prerequisites
ObjectivePrerequisites for taking this course.

Verify that you have the right background for this course.

Queries, Cursors and Views is an introductory-level course. It does require the following, however:
  1. Experience Using the Microsoft Windows NT Server network operating system
  2. Familiarity with the definition, theory, and underlying function of relational databases
  3. Understanding of basic ANSI SQL statements.
  4. Completion of Creating a Database, the first course in this series, or equivalent understanding of relational concepts, basic Transact-SQL statements, and how to create databases and tables.
In the next lesson, what is required to take this course will be discussed.

Set-Based Queries

SQL Server is designed to handle data in sets. SQL is a declarative language, meaning that the SQL query describes the problem, and the Query Optimizer generates an execution plan to resolve the problem as a set.
Iterative T-SQL code is code that acts upon data one row at a time instead of as a set. It is typically implemented via cursors and forces the database engine to perform thousands of wasteful single-row operations, instead of handling the problem in one larger, more efficient set. The performance cost of these single-row operations is huge. Depending on the task, SQL cursors perform about half as well as set-based code, and the performance differential grows with the size of the data. This is why set-based queries, based on an obvious physical schema, are so critical to database performance.
A good physical schema and set-based queries set up the database for excellent indexing, further improving the performance of the query