Tải bản đầy đủ (.pdf) (12 trang)

Tài liệu Querying Microsoft SQL Server 2000 with Transact-SQL Delivery Guide pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (188.25 KB, 12 trang )






Part Number: X05-88987
Course Number: 2071A


Released: 9/2000
Delivery Guide
Querying Microsoft
SQL Server 2000 with
Transact-SQL

Information in this document is subject to change without notice. The names of companies,
products, people, characters, and/or data mentioned herein are fictitious and are in no way intended
to represent any real individual, company, product, or event, unless otherwise noted. Complying
with all applicable copyright laws is the responsibility of the user. No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of Microsoft Corporation. If, however, your only
means of access is electronic, permission to print one copy is hereby granted.

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.

 2000 Microsoft Corporation. All rights reserved.

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 companies, products, people, characters, and/or data mentioned herein are fictitious
and are in no way intended to represent any real individual, company, product, or event, unless
otherwise noted.

Other product and company names mentioned herein may be the trademarks of their respective
owners.

Project Lead: Cheryl Hoople
Instructional Designer: Cheryl Hoople
Technical Lead: LeRoy Tuttle
Program Manager: LeRoy Tuttle
Graphic Artist: Kimberly Jackson (Independent Contractor)
Editing Manager: Lynette Skinner
Editor: Wendy Cleary
Editorial Contributor: Elizabeth Reese
Copy Editor: Bill Jones (S&T Consulting)
Production Manager: Miracle Davis
Production Coordinator: Jenny Boe
Production Tools Specialist: Julie Challenger
Production Support: Lori Walker (S&T Consulting)
Test Manager: Sid Benavente
Courseware Testing: Testing Testing 123
Classroom Automation: Lorrin Smith-Bates
Creative Director, Media/Sim Services: David Mahlmann
Web Development Lead: Lisa Pease
CD Build Specialist: Julie Challenger
Online Support: David Myka (S&T Consulting)

Localization Manager: Rick Terek
Operations Coordinator: John Williams
Manufacturing Support: Laura King; Kathy Hershey
Lead Product Manager, Release Management: Bo Galford
Lead Product Manager: Margo Crandall
Group Manager, Courseware Infrastructure: David Bramble
Group Product Manager, Content Development: Dean Murray
General Manager: Robert Stewart


Course Number: 2071A
Part Number: X05-88987
Released: 9/2000
Querying Microsoft SQL Server 2000 with Transact-SQL iii


Contents
Introduction
Introduction..............................................................................................................1
Course Materials ......................................................................................................2

Prerequisites.............................................................................................................3

Course Outline .........................................................................................................4

Appendices...............................................................................................................6

Microsoft Certified Professional Program ...............................................................7

Facilities...................................................................................................................9


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...............................................................29

Review ...................................................................................................................33

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


Module 4: Grouping and Summarizing Data
Overview................................................................................................................. 1

Listing the TOP n Values........................................................................................ 2


Using Aggregate Functions..................................................................................... 4

GROUP BY Fundamentals ..................................................................................... 8

Generating Aggregate Values Within Result Sets ................................................ 13

Using the COMPUTE and COMPUTE BY Clauses ............................................ 22

Recommended Practices ....................................................................................... 25

Lab A: Grouping and Summarizing Data ............................................................. 26

Review .................................................................................................................. 40

Module 5: Joining Multiple Tables
Overview................................................................................................................. 1

Using Aliases for Table Names............................................................................... 2

Combining Data from Multiple Tables................................................................... 3

Combining Multiple Result Sets ........................................................................... 18

Recommended Practices ....................................................................................... 20

Lab A: Querying Multiple Tables......................................................................... 21

Review .................................................................................................................. 29


Module 6: Working with Subqueries
Overview................................................................................................................. 1

Introduction to Subqueries...................................................................................... 2

Using a Subquery as a Derived Table..................................................................... 4

Using a Subquery as an Expression ........................................................................ 5

Using a Subquery to Correlate Data........................................................................ 6

Using the EXISTS and NOT EXISTS Clauses..................................................... 13

Recommended Practices ....................................................................................... 15

Lab A: Working with Subqueries ......................................................................... 16

Review .................................................................................................................. 27

Module 7: Modifying Data
Overview................................................................................................................. 1

Using Transactions.................................................................................................. 2

Inserting Data.......................................................................................................... 4

Deleting Data ........................................................................................................ 15

Updating Data ....................................................................................................... 20


Performance Considerations ................................................................................. 24

Recommended Practices ....................................................................................... 25

Lab A: Modifying Data......................................................................................... 26

Review .................................................................................................................. 39

Module 8: Querying Full-Text Indexes
Overview................................................................................................................. 1

Introduction to Microsoft Search Service ............................................................... 2

Microsoft Search Service Components................................................................... 3

Getting Information About Full-Text Indexes ........................................................ 5

Writing Full-Text Queries....................................................................................... 7

Recommended Practices ....................................................................................... 14

Lab A: Querying Full-Text Indexes...................................................................... 15

Review .................................................................................................................. 21

Querying Microsoft SQL Server 2000 with Transact-SQL v


Module 9: Introduction to Programming Objects
Overview..................................................................................................................1


Displaying the Text of a Programming Object ........................................................2

Introduction to Views ..............................................................................................4

Advantages of Views ...............................................................................................6

Creating Views ........................................................................................................7

Introduction to Stored Procedures..........................................................................12

Introduction to Triggers .........................................................................................15

Introduction to User-defined Functions .................................................................16

Recommended Practices ........................................................................................21

Lab A: Working with Views..................................................................................22

Review ...................................................................................................................28
Appendix A
Appendix B


×