Professional Documents
Culture Documents
Transact-SQL
Delivery Guide
Course Number: 2071B
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
Microsoft, BackOffice, MS-DOS, PowerPoint, Visual Studio, Windows, Windows Media, and
Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the
U.S.A. and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Contents
Introduction
Course Materials ......................................................................................................2
Prerequisites.............................................................................................................3
Course Outline .........................................................................................................4
Appendices...............................................................................................................6
Microsoft Official Curriculum .................................................................................7
Microsoft Certified Professional Program ...............................................................8
Facilities.................................................................................................................10
Module 1: Introduction to Transact-SQL
Overview..................................................................................................................1
The Transact-SQL Programming Language ............................................................2
Types of Transact-SQL Statements .........................................................................3
Transact-SQL Syntax Elements ...............................................................................7
Lab A: Using SQL Server Books Online...............................................................30
Review ...................................................................................................................34
Module 2: Using Transact-SQL Querying Tools
Overview..................................................................................................................1
SQL Query Analyzer ...............................................................................................2
Using the Object Browser Tool in SQL Query Analyzer ........................................3
Using Templates in SQL Query Analyzer ...............................................................5
Using the osql Utility ...............................................................................................6
Executing Transact-SQL Statements .......................................................................8
Recommended Practices ........................................................................................14
Lab A: Creating and Executing Transact-SQL Scripts ..........................................15
Review ...................................................................................................................21
Module 3: Retrieving Data
Overview..................................................................................................................1
Retrieving Data by Using the SELECT Statement ..................................................2
Filtering Data ...........................................................................................................8
Formatting Result Sets...........................................................................................20
How Queries Are Processed ..................................................................................28
How Queries Are Cached Automatically...............................................................29
Performance Considerations ..................................................................................31
Recommended Practices ........................................................................................32
Lab A: Retrieving Data and Manipulating Result Sets ..........................................33
Review ...................................................................................................................45
iv Querying Microsoft® SQL Server™ 2000 with Transact-SQL
Description
This course provides students with the technical skills required to write basic
Transact-SQL queries for Microsoft® SQL Server™ 2000.
This is a revised two-day course. The course content reflects the need to focus
on querying with Transact-SQL. The material comes primarily from course
2071A, Querying Microsoft SQL Server 2000 with Transact SQL.
This revised course is a prerequisite for course 2073A, Programming a
Microsoft SQL Server 2000 Database and course 2072A, Administering a
Microsoft SQL Server 2000 Database.
Audience
This course is designed for SQL Server database administrators, implementers,
system engineers, and developers who are responsible for writing queries.
Student Prerequisites
This course requires that students meet the following prerequisites:
! Experience using the Microsoft Windows® operating system.
! An understanding of basic relational database concepts, including:
• Logical and physical database design.
• Data integrity concepts.
• Relationships between tables and columns (primary key and foreign key,
one-to-one, one-to-many, many-to-many).
• How data is stored in tables (rows and columns).
For students who do not meet these prerequisites, the following course
provides students with the necessary knowledge and skills:
• Course 1609, Designing Data Services and Data Models
! Familiarity with the role of the database administrator.
viii Querying Microsoft® SQL Server™ 2000 with Transact-SQL
Course Objectives
At the end of this course, the student will be able to:
! Describe the uses of and ways to execute the Transact-SQL language.
! Use querying tools.
! Write SELECT queries to retrieve data.
! Group and summarize data using Transact-SQL.
! Join data from multiple tables.
! Write queries that retrieve and modify data by using subqueries.
! Modify data in tables.
! Query text fields with full-text search.
! Describe how to create programming objects.
Querying Microsoft® SQL Server™ 2000 with Transact-SQL ix
Course Timing
The following schedule is an estimate of the course timing. Your timing may
vary.
Day 1
Start End Module
8:30 9:00 Introduction
9:00 10:00 Module 1: Introduction to Transact-SQL
10:00 10:15 Lab A: Using SQL Server Books Online
10:15 10:30 Break
10:30 11:00 Module 2: Using Transact-SQL Querying Tools
11:00 11:30 Lab A: Creating and Executing Transact-SQL Scripts
11:30 12:15 Module 3: Retrieving Data
12:15 1:15 Lunch
1:15 2:00 Lab A: Retrieving Data and Manipulating Results Sets
2:00 2:45 Module 4: Grouping and Summarizing Data
2:45 3:00 Break
3:00 3:45 Lab A: Grouping and Summarizing Data
3:45 4:45 Module 5: Joining Multiple Tables
4:45 5:30 Lab A: Querying Multiple Tables
Day 2
Start End Module
8:30 9:00 Day 1 review
9:00 9:45 Module 6: Working with Subqueries
9:45 10:15 Lab A: Working with Subqueries
10:15 10:30 Break
10:30 11:15 Module 7: Modifying Data
11:15 12:15 Lab A: Modifying Data
12:15 1:15 Lunch
1:15 2:00 Module 8: Querying Full-Text Indexes
1:45 2:45 Lab A: Querying Full-Text Indexes
2:45 3:00 Break
3:00 4:00 Module 9: Introduction to Programming Objects
4:00 4:30 Lab A: Working with Views
x Querying Microsoft® SQL Server™ 2000 with Transact-SQL
Document Conventions
The following conventions are used in course materials to distinguish elements
of the text.
Convention Use