Escolar Documentos
Profissional Documentos
Cultura Documentos
M I CRO S O F T
L EA RN I N G
PRO DU C T
2778A
Writing Queries Using Microsoft SQL Server 2008 Transact-SQL Companion Content
Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. 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. The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. 2008 Microsoft Corporation. All rights reserved. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners.
1-1
Module 1
Getting Started with Databases and Transact-SQL in SQL Server 2008
Contents:
Lesson 1: Overview of SQL Server 2008 Lesson 2: Overview of SQL Server Databases Lesson 3: Overview and Syntax Elements of T-SQL Lesson 4: Working with T-SQL Scripts Lesson 5: Using T-SQL Querying Tools Module Reviews and Takeaways Lab Review Questions and Answers 2 5 7 9 11 13 15
1-2
Lesson 1
1-3
1-4
Additional Reading
Overview of Client/Server Architecture
Chapter 7 - Client/Server Architecture File-Server vs. Client/Server
1-5
Lesson 2
1-6
Additional Reading
Overview of Relational Databases
Databases Relational Database Components Database Engine Concepts Relational Databases
What is Normalization?
Normalization SQL Database Normalization Rules
1-7
Lesson 3
1-8
Additional Reading
A History and Definition of ANSI SQL and T-SQL
Using Common Table Expressions
Control-of-flow Statements
Control-of-Flow Conditional Statement Syntax GOTO (Transact-SQL)
1-9
Lesson 4
1-10
Additional Reading
What are Batch Directives?
ELSE (IF...ELSE)
1-11
Lesson 5
1-12
Additional Reading
Tools for Querying SQL Server 2008 Databases
Query Tools bcp Utility sqlcmd Utility
1-13
1-14
Tools
Tool
Microsoft SQL Server Management Studio
Use for
Where to find it
Managing SQL server Start | All Programs | Microsoft SQL Server 2008 databases and tables.
SQL Server Business Managing SQL server Start | All Programs | Microsoft SQL Server 2008 Intelligence Development applications. Studio
1-15
2-1
Module 2
Querying and Filtering Data
Contents:
Lesson 1: Using the SELECT Statement Lesson 2: Filtering Data Lesson 3: Working with NULL Values Lesson 4: Formatting Result Sets Lesson 5: Performance Considerations for Writing Queries Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 14 18 20 21
2-2
Lesson 1
2-3
2-4
2-5
Additional Reading
Elements of the SELECT Statement
Parts of a SELECT Statement Query Fundamentals
2-6
Lesson 2
Using Variables
Contents:
Question and Answers Detailed Demo Steps Additional Reading 7 8 9
2-7
2-8
2-9
Additional Reading
Retrieving Specific Rows in a Table
Predicate (Transact-SQL) WHERE (Transact-SQL) Search Condition (Transact-SQL)
Operator Precedence
Logical Operators (Transact-SQL)
2-10
Lesson 3
2-11
2-12
4. 5.
6.
7.
2-13
Additional Reading
Considerations for Working with NULL Values
Null Values Using Sparse Columns
2-14
Lesson 4
2-15
Using Expressions
Question: The above examples show how expressions can be used. What other ways do think you will use expressions to create queries? Answer: They can be used as possible values in comparisons, static values in derived columns, static values in concatenated columns.
2-16
3.
5. 6. 7. 8.
2-17
Additional Reading
Sorting Data
ORDER BY Clause (Transact-SQL) Sorting Rows with ORDER BY
Using Expressions
+ (String Concatenation) (Transact-SQL) Functions (Transact-SQL) Derived Column Transformation
2-18
Lesson 5
2-19
Additional Reading
How SQL Server Processes Transact-SQL Queries
SQL Statement Processing Query Performance Query Tuning Recommendations
2-20
2-21
The following functions can be used to accommodate NULL values: o o ISNULL() will replace a NULL value with a given value in the data set. COALESCE() allows you to designate a number of values that can be substituted for NULL values. Each column or value listed is tested for a NULL value and the first one to not have a NULL value is used in the data set. IS NULL is used to test for NULL values in a column in the WHERE clause.
Question: When performing string comparisons on a column you can use LIKE, CONTAINS, and FREETEXT. What are the differences and when would each be best used? Answer: LIKE uses wildcards to search for partial matches in text columns. LIKE is best used when the strings are relatively short and spelling is the main consideration for the search. CONTAINS uses a word or list of words to search strings in a column. CONTAINS is best used for larger columns and when derivatives of the word are also desired such as drive, drove, driving, and driven. FREETEXT uses a word or list of words on large text data that has been indexed using Full Text indexing. FREETEXT also allows you to search for derivatives of the word or words in the list.
3-1
Module 3
Grouping and Summarizing Data
Contents:
Lesson 1: Summarizing Data by Using Aggregate Functions Lesson 2: Summarizing Grouped Data Lesson 3: Ranking Grouped Data Lesson 4: Creating Crosstab Queries Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 13 15 16
3-2
Lesson 1
3-3
3-4
Enter and then run the following query to calculate the average number of vacation hours each employee has: o SELECT AVG(VacationHours) FROM HumanResources.Employee;
Enter and then run the following query to calculate the maximum number of vacation hours held by an employee: o SELECT MAX(VacationHours) FROM HumanResources.Employee;
Enter and then run the following query to calculate the total number of vacation hours held by employees: o SELECT SUM(VacationHours) FROM HumanResources.Employee;
3-5
Additional Reading
Using Aggregate Functions Native to SQL Server
Summarizing Data Deterministic and Nondeterministic Functions Aggregate Functions
3-6
Lesson 2
3-7
3-8
GO SELECT ProductKey, OrderDateKey, DueDateKey, ShipDateKey,SUM (SalesAmount) AS [Sales] FROM dbo.FactInternetSales GROUP BY CUBE(ProductKey, OrderDateKey, DueDateKey, ShipDateKey);
3-9
Additional Reading
Using the GROUP BY Clause
GROUP BY (Transact-SQL)
3-10
Lesson 3
3-11
3-12
Additional Reading
What is Ranking?
Ranking Functions (Transact-SQL) Over Clause (Transact-SQL)
3-13
Lesson 4
3-14
Additional Reading
How the PIVOT and UNPIVOT Operators Work
Using PIVOT and UNPIVOT
3-15
3-16
4-1
Module 4
Joining Data from Multiple Tables
Contents:
Lesson 1: Querying Multiple Tables by Using Joins Lesson 2: Applying Joins for Typical Reporting Needs Lesson 3: Combining and Limiting Result Sets Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 14 16
4-2
Lesson 1
4-3
4-4
4-5
Additional Reading
Fundamentals of Joins
PRIMARY KEY Constraints FOREIGN KEY Constraints
4-6
Lesson 2
4-7
4-8
4-9
Additional Reading
Joining Tables in a User-Defined Function
Views
4-10
Lesson 3
4-11
Question: How do you think rows are returned from a SELECT TOP statement that also has an ORDER BY clause? Answer: If a SELECT statement that includes TOP also has an ORDER BY clause, the rows to be returned are selected from the ordered result set. The whole result set is built in the specified order and the top n rows in the ordered result set are returned. Question: What conditions must be met in order to use TABLESAMPLE to return a sample from a large table? Answer: You can use TABLESAMPLE to quickly return a sample from a large table when either of the following conditions is true: The sample does not have to be a truly random sample at the level of individual rows. Rows on individual pages of the table are not correlated with other rows on the same page.
4-12
4-13
Additional Reading
Limiting Result Sets by Using the EXCEPT and INTERSECT Operators
Collation Precedence (Transact-SQL)
4-14
4-15
4-16
5-1
Module 5
Working with Subqueries
Contents:
Lesson 1: Writing Basic Subqueries Lesson 2: Writing Correlated Subqueries Lesson 3: Comparing Subqueries with Joins and Temporary Tables Lesson 4: Using Common Table Expressions Module Reviews and Takeaways Lab Review Questions and Answers 2 6 9 11 15 16
5-2
Lesson 1
5-3
Question: What results were returned by the SELECT statement that contained an ANY expression and why? Answer: The products whose list prices are greater than or equal to the maximum list price of any product subcategory.
5-4
5-5
Additional Reading
What are Subqueries?
ALL (Transact-SQL) SOME | ANY (Transact-SQL)
5-6
Lesson 2
5-7
Question: What results did the correlated subqueries return? Answer: Sales where the quantity is less than the average quantity for sales of that product.
5-8
5-9
Lesson 3
5-10
Additional Reading
Temporary Tables
table (Transact-SQL)
5-11
Lesson 4
5-12
5-13
5-14
Additional Reading
Writing Recursive Queries by Using Common Table Expressions
Recursive Queries Using Common Table Expressions
5-15
The EXISTS keyword is important because frequently there is no alternative, nonsubquery formulation. Although some queries that are created with EXISTS cannot be expressed any other way, many queries can use IN or a comparison operator modified by ANY or ALL to achieve similar results.
5-16
6-1
Module 6
Modifying Data in Tables
Contents:
Lesson 1: Inserting Data into Tables Lesson 2: Deleting Data from Tables Lesson 3: Update Data in Tables Lesson 4: Overview of Transactions Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 14 18 20
6-2
Lesson 1
6-3
6-4
6-5
Additional Reading
INSERT Fundamentals
INSERT (Transact SQL)
6-6
Lesson 2
6-7
6-8
6-9
Additional Reading
Delete Fundamentals
DELETE (Transact-SQL)
6-10
Lesson 3
6-11
6-12
6-13
Additional Reading
UPDATE Fundamentals
UPDATE (Transact-SQL) Changing Data by Using UPDATE
6-14
Lesson 4
Overview of Transactions
Contents:
Question and Answers Detailed Demo Steps Additional Reading 15 16 17
6-15
6-16
6-17
Additional Reading
Transaction Fundamentals
Transactions (Database Engine) Distributed Transactions (Database Engine)
6-18
6-19
rows violates a constraint, the statement is canceled, an error is returned, and no rows are removed. If you want to delete all the rows in a table, use the DELETE statement without specifying a WHERE clause, or use TRUNCATE TABLE. TRUNCATE TABLE is faster than DELETE and uses fewer system and transaction log resources. Note: if you do use the TRUNCATE statement on a table, you will reset the identity seed of any IDENTITY column in that table.
6-20
7-1
Module 7
Querying Metadata, XML, and Full-Text Indexes
Contents:
Lesson 1: Querying Metadata Lesson 2: Overview of XML Lesson 3: Querying XML Data Lesson 4: Overview of Full-Text Indexes Lesson 5: Querying Full-Text Indexes Module Reviews and Takeaways Lab Review Questions and Answers 2 6 8 13 15 19 20
7-2
Lesson 1
Querying Metadata
Contents:
Question and Answers Detailed Demo Steps Additional Reading 3 4 5
7-3
7-4
FROM sys.tables;
Querying metadata using the Information Schema Open a new query window and enter the following query:
SELECT COLUMN_NAME
Querying metadata using Dynamic Management Views Open a new query window and enter the following query:
SELECT count(*), Command GROUP BY Command
FROM sys.dm_exec_requests
Querying metadata using System Stored Procedures and Functions Open a new query window and enter the following query:
EXEC sp_columns @table_name = N'Department', @table_owner = N'HumanResources';
7-5
Additional Reading
What Is Metadata?
Managing Metadata in SQL Server
Compatibility Views
Compatibility Views (Transact-SQL)
7-6
Lesson 2
Overview of XML
Contents:
Additional Reading 7
7-7
Additional Reading
What Is XML?
Understanding XML in SQL Server
7-8
Lesson 3
7-9
7-10
FROM Sales.Customer Cust, Sales.SalesOrderHeader OrderHeader WHERE Cust.CustomerID = OrderHeader.CustomerID ORDER BY Cust.CustomerID FOR XML AUTO
Using OpenXML to query XML Open a new query window and enter the following query:
DECLARE @xml_text VARCHAR(4000), @i INT SELECT @xml_text = ' <root> <person LastName="White" FirstName="Johnson" Title="Mr."/>
<person LastName="Green" FirstName="Marjorie" Title="Mrs."/> EXEC sp_xml_preparedocument @i OUTPUT, @xml_text SELECT * FROM OPENXML(@i, '/root/person') WITH (LastName nvarchar(50), FirstName nvarchar(50), Title nvarchar(8)) EXEC sp_xml_removedocument @i
On the toolbar, click Execute Using XQuery to query XML Open a new query window and enter the following query:
SELECT JobCandidateID,
"http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume"; concat((/ns:Resume/ns:Name/ns:Name.First)[1], " ", (/ns:Resume/ns:Name/ns:Name.Last)[1])', 'nvarchar(60)') AS FullName, Resume.query('declare namespace ns= for $ed in /ns:Resume/ns:Education
7-11
FROM HumanResources.JobCandidate
7-12
Additional Reading
Using For XML to Generate XML
FOR XML Support for String Data Types
Shredding XML
Using OPENXML
7-13
Lesson 4
7-14
Additional Reading
What Are Full-Text Indexes?
SQL Server 2008 Full-Text Search Internals and Enhancements
7-15
Lesson 5
7-16
7-17
EXEC sp_fulltext_table 'Production.Product', 'create', 'Cat_Name', EXEC sp_fulltext_column 'Production.Product','Name','add'; EXEC sp_fulltext_table 'Production.Product','activate'; EXEC sp_fulltext_table 'Production.Product ', 'Start_change_tracking';
Querying a Full Text Index using predicates Open a new query window and enter the following query:
SELECT Name
FROM Production.Product
Querying a Full Text Index using functions Open a new query window and enter the following query:
SELECT Product.ProductID, Product.Name, Keys.Rank FROM Production.Product INNER JOIN FREETEXTTABLE(Production.Product, Name, 'Chain',LANGUAGE 'English',2) AS Keys ON Product.ProductID = Keys.[KEY];
7-18
Additional Reading
Overview of Full-Text Search
SQL Server 2008 Full-Text Search Internals and Enhancements
Full-Text Functions
Full-Text Search Query Fundamentals
7-19
7-20
8-1
Module 8
Using Programming Objects for Data Retrieval
Contents:
Lesson 1: Encapsulating Queries by Using Views Lesson 2: Encapsulating Expressions by Using User-Defined Functions Lesson 3: Overview of Stored Procedures and Triggers Lesson 4: Overview of Triggers Lesson 5: Writing Distributed Queries Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 14 18 20 21
8-2
Lesson 1
8-3
8-4
FROM HumanResources.Employee
Query a view
Open a new query window and enter the following query:
SELECT * FROM vwEmployeeLogins
8-5
Additional Reading
What Are Views?
SQL Views
Indexed Views
Creating Indexed Views
Partitioned Views
Using Partitioned Views
8-6
Lesson 2
8-7
8-8
8-9
Additional Reading
What Are User-Defined Functions
User-defined Function Basics
8-10
Lesson 3
8-11
8-12
8-13
Additional Reading
What Are Stored Procedures?
CREATE PROCEDURE (Transact-SQL)
8-14
Lesson 4
Overview of Triggers
Contents:
Question and Answers Detailed Demo Steps Additional Reading 15 16 17
8-15
8-16
DECLARE @name nvarchar(50) SELECT @name = Name FROM inserted BEGIN END END GO IF len(@name) < 5 ROLLBACK TRANSACTION
8-17
Additional Reading
What Are Triggers?
CREATE TRIGGER (Transact-SQL)
8-18
Lesson 5
8-19
Additional Reading
How SQL Server? Works With Heterogeneous Data
Distributed Queries
8-20
8-21
9-1
Module 9
Using Advanced Querying Techniques
Contents:
Lesson 1: Considerations for Querying Data Lesson 2: Working with Data Types Lesson 3: Cursors and Set-Based Queries Lesson 4: Dynamic SQL Lesson 5: Maintaining Query Files Module Reviews and Takeaways Lab Review Questions and Answers 2 6 10 14 18 20 22
9-2
Lesson 1
9-3
Implicit Conversion
Question: When would you want to avoid implicit conversions? Answer: Any time that you need to insure that an operation returns a specific data type, you should avoid implicit conversions.
9-4
Viewing estimated and actual execution plans with SQL Server Profiler
Start SQL Server Profiler and create a new trace. In the Events tab, under Performance, select some of the different Showplan events and start the trace. In SQL Server Management Studio, execute the query again and review the execution plan in SQL Server Profiler.
9-5
Additional Reading
Execution Plans
Execution Plans
Implicit Conversion
Data Type Conversions Implicit Conversions
9-6
Lesson 2
9-7
9-8
o
o o o
CreateTableIndex
InsertRootTerritory InsertChildTerritory CreateTerritorySP this creates a stored procedure that helps automate the entry of additional child nodes PopulateTerritoryTable this will not work without first running CreateTerritorySP
9-9
Additional Reading
Recommendations for Querying Date/Time Data
Using Time and Date Data Date and Time Data Types and Functions
9-10
Lesson 3
9-11
9-12
The query for the set-based approach can also be found in E:\MOD09\Democode\PriceUpdateSetBased.sql.
9-13
Additional Reading
Understanding Cursors
Cursors (Database Engine)
Cursor Implementations
Cursor Implementations
Using Cursors
Cursors (Database Engine) DECLARE CURSOR: Using DEALLOCATE
9-14
Lesson 4
Dynamic SQL
Contents:
Question and Answers Detailed Demo Steps Additional Reading 15 16 17
9-15
9-16
Review and execute the query to see how a dynamic SQL string is built then passes to sp_executesql.
9-17
Additional Reading
Introducing Dynamic SQL
Dynamic SQL
9-18
Lesson 5
9-19
Additional Reading
What are Versioning and Source Control?
Source Control Basics
9-20
Issue
Cannot implicitly or explicitly convert string or number data to xml data type Implicit conversions to binary data type produces unexpected results
Troubleshooting tip
Conversion to the xml data type will fail if the XML is not well-formed. If the binary data type is too small for the conversion, the leading digits are silently truncated. Conversion will succeed, but the results will be wrong. If the integer is too big for the character conversion, an asterisk is used in implicit conversions.
Converting integers to character data types implicitly results in an asterisk (*) instead of the correct value.
9-21
Test the size and data type of input and enforce appropriate limits. This can help prevent deliberate buffer overruns. Never build Transact-SQL statements directly from user input. Use stored procedures to validate user input. Never concatenate user input that is not validated. String concatenation is the primary point of entry for script injection. Do not accept the following strings in fields from which file names can be constructed: AUX, CLOCK$, COM1 through COM8, CON, CONFIG$, LPT1 through LPT8, NUL, and PRN.
9-22
R-1
Resources
Contents:
Microsoft Learning TechNet and MSDN Content Knowledgebase Communities Books 2 3 9 10 11
R-2
Microsoft Learning
This section describes various Microsoft Learning programs and offerings. Microsoft Skills Assessments Describes the skills assessment options available through Microsoft. Microsoft Learning Describes the training options available through Microsoft face-to-face or self-paced. Microsoft Certification Program Details how to become a Microsoft Certified Professional, Microsoft Certified Database Administrators, and more. Microsoft Learning Support o To provide comments or feedback about the course, send e-mail to support@mscourseware.com. To ask about the Microsoft Certification Program (MCP), send e-mail to mcphelp@microsoft.com
R-3
Module 1
Chapter 7 - Client/Server Architecture File-Server vs. Client/Server Editions and Components of SQL Server 2008 Installing SQL Server 2005 SQL Server Overview Components of the SQL Server Database Engine Considerations for Installing the SQL Server Database Engine Databases Relational Database Components Database Engine Concepts Relational Databases Normalization SQL Database Normalization Rules Identifiers Using Extended Properties on Database Objects Deprecated Database Engine Features in SQL Server 2008 Data Types (Transact-SQL) Using Common Table Expressions GRANT (Transact-SQL) Query Fundamentals Transact-SQL Syntax Conventions (Transact-SQL) Transact-SQL Reference (Transact-SQL) Functions (Transact-SQL) Transact-SQL Variables Expressions (Transact-SQL) Control-of-Flow Conditional Statement Syntax GOTO (Transact-SQL) ELSE (IF...ELSE) TRY...CATCH (Transact-SQL) RAISERROR (Transact-SQL)
R-4
/*...*/ (Comment) (Transact-SQL) -- (Comment) (Transact-SQL) Using Comments bcp Utility sqlcmd Utility Query Tools Features in SQL Server Management Studio Developing Solutions and Projects in SQL Server Management Studio Introduction to Solutions, Projects, and Items Introducing SQL Server Management Studio How to: Create New Solutions Using Solution Explorer Connect to (import) SQL Server data Use Microsoft Query to retrieve external data
Module 2
+ (String Concatenation) (Transact-SQL) Analyzing a Query Assigning Result Set Column Names BETWEEN (Transact-SQL) Checklist for Analyzing Slow-Running Queries COALESCE (Transact-SQL) Comparison Operators Comparison Operators (Transact-SQL) CONTAINS (Transact-SQL) Derived Column Transformation Eliminating Duplicates with DISTINCT Expressions (Transact-SQL) FREETEXT (Transact-SQL) Functions (Transact-SQL) IN (Transact-SQL) ISNULL (Transact-SQL) LIKE (Transact-SQL) Logical Operator Precedence Logical Operators (Transact-SQL)
R-5
Null Values NULLIF (Transact-SQL) Operator Precedence (Transact-SQL) ORDER BY Clause (Transact-SQL) Parts of a SELECT Statement Pattern Matching in Search Conditions Predicate (Transact-SQL) Query Fundamentals Query Performance Query Tuning Recommendations Search Condition (Transact-SQL) SELECT Clause (Transact-SQL) SELECT Examples (Transact-SQL) Sorting Rows with ORDER BY SQL Statement Processing SUBSTRING (Transact-SQL) Troubleshooting Poor Query Performance: Cardinality Estimation Troubleshooting Queries Using Sparse Columns Using Table Aliases WHERE (Transact-SQL)
Module 3
Summarizing Data Deterministic and Nondeterministic Functions Aggregate Functions COUNT (Transact-SQL) CREATE AGGREGATE (Transact-SQL) CLR User-Defined Aggregates Invoking CLR User-Defined Aggregate Functions GROUP BY (Transact-SQL) HAVING (Transact-SQL) COMPUTE (Transact-SQL) GROUPING SETS Equivalents Ranking Functions (Transact-SQL)
R-6
Over Clause (Transact-SQL) RANK (Transact-SQL) DENSE_RANK (Transact-SQL) ROW_NUMBER (Transact-SQL) NTILE (Transact-SQL) Using PIVOT and UNPIVOT SQL Server Overview
Module 4
PRIMARY KEY Constraints FOREIGN KEY Constraints Views Collation Precedence (Transact-SQL)
Module 5
ALL (Transact-SQL) OME | ANY (Transact-SQL) Craig Freedman's SQL Server Blog: Scalar Subqueries table (Transact-SQL)
Module 6
INSERT (Transact SQL) Adding Rows by Using INSERT and SELECT INSERT (Transact SQL) INSERT (Transact SQL) OUTPUT Clause (Transact-SQL) DELETE (Transact-SQL) TRUNCATE TABLE (Transact-SQL) UPDATE (Transact-SQL) Changing Data by Using UPDATE Changing Data by Using the SET Clause Changing Data by Using the FROM Clause Changing Data by Using the WHERE Clause Transactions (Database Engine) Write-Ahead Transaction Log Checkpoints and the Active Portion of the Log BEGIN TRANSACTION (Transact-SQL)
R-7
COMMIT TRANSACTION (Transact-SQL) SET XACT_ABORT (Transact-SQL) TRY...CATCH (Transact-SQL) Using TRY...CATCH in Transact-SQL Isolation Levels in the Database Engine Nesting Transactions
Module 7
Managing Metadata in SQL Server Compatibility Views (Transact-SQL) Querying the SQL Server System Catalog Information Schema Views (Transact-SQL) Dynamic Management Views and Functions Viewing Database Metadata Understanding XML in SQL Server Using XML Data Types FOR XML Support for String Data Types Using OPENXML How to use XQuery to query XML data Reporting Services Using XML and Web Service Data Sources SQL Server 2008 Full-Text Search Internals and Enhancements CONTAINS (Transact-SQL) FREETEXT (Transact-SQL) Full-Text Search Query Fundamentals Integrating Full-Text Search and Transact-SQL Predicates
Module 8
SQL Views CREATE VIEW (Transact-SQL) Creating Indexed Views Using Partitioned Views User-defined Function Basics CREATE FUNCTION (Transact-SQL) CREATE PROCEDURE (Transact-SQL) CREATE TRIGGER (Transact-SQL) Distributed Queries
R-8
Module 9
Execution Plans Data Type Conversions Implicit Conversions Using CAST and CONVERT Data Type Precedence Using Time and Date Data Date and Time Data Types and Functions hierarchyid Using the hierarchyid Data Type Cursors (Database Engine) Cursor Implementations DECLARE CURSOR: Using DEALLOCATE JOIN Fundamentals Manipulating Result Sets Query Fundamentals Dynamic SQL sp_executesql Using sp_executesql EXECUTE SQL Injection SQL Injection Protection Source Control Basics Team Foundation Server Version control with Team Foundation Server TFS support for SQL Server 2008 Visual SourceSafe 2005
R-9
Knowledge Base
This section includes content from Microsoft TechNet and MSDN that provides in-depth discussion on technical topics related to SQL Server 2008 Knowledge Base Query Tools
Microsoft
Schema Diagrams for the database can be found here: http://www.codeplex.com/MSFTDBProdSamples/Wiki/View.aspx?title=AWSchemaDiag&referring Title=Home Description of the database normalization basics
R-10
Communities
The Professional Association for SQL Server (PASS) is an independent, not-for-profit association, dedicated to supporting, educating, and promoting the Microsoft SQL Server community. Offering a multitude of networking channels from local user groups and special interest groups (SIGs) to webcasts and the annual PASS Summit the largest gathering of SQL Server professionals in the world PASS enables knowledge sharing, in-depth learning, access to the Microsoft SQL Server team, and the ability to influence the direction of SQL Server technologies. For more information and your free membership, visit www.sqlpass.org.
Blogs
Query Processing -- introduction to the blog!
R-11
Books
This section describes the various books that may be of use to SQL Server 2008 DBAs. Introducing Microsoft SQL Server 2008, Microsoft Corporation, Peter DeBetta
R-12
Courseware Feedback
Send all courseware feedback to support@mscourseware.com. We truly appreciate your time and effort. We review every e-mail received and forward the information on to the appropriate team. Unfortunately, because of volume, we are unable to provide a response but we may use your feedback to improve your future experience with Microsoft Learning products.
Reporting Errors
When providing feedback, include the training product name and number in the subject line of your email. When you provide comments or report bugs, please include the following: Document Page number or location Complete description of the error or suggested change
Please provide any details that are necessary to help us verify the issue.
Important All errors and suggestions are evaluated, but only those that are validated are added to the product Knowledge Base article.