The Real MCTS SQL Server 2008 Exam 70-432 Prep Kit: Database Implementation and Maintenance
Copyright Page
Technical Editor
Lead Authors
Contributing Authors
Contents
Chapter 1: MCTS SQL Server 2008 Exam 432 New Features in SQL Server 2008
Introduction
A Word About the Test
New Feature Overview
Installation
Compressed Backups
Enhanced Configuration and Management of Audits
New Table Value Parameter
FileStream Data Types
Sparse Column Support
Encryption Enhancements
Key Management and Encryption
High Availability
Performance
Performance Data Management
Resource Governor (similar to Query Governor)
Freeze Plan
SQL Server 2008 Declarative Management Framework
Development Improvements
LINQ Support
MERGE Statement
Spatial Data Type
Analysis Services Improvements
ETL/SSIS Enhancements
Reporting Services
No Longer Requires IIS
Better Graphing
Export to Word Support
Deprecated Features
Discontinued Features
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 2: MCTS SQL Server 2008 Exam 432 Installing SQL Server 2008
Introduction
SQL Versions, Requirements, Features, and Differences
Planning Your Installation
Upgrade Tools
Hardware Requirements: CPU, Memory, and Disk
Operating System Requirements
Software Requirements
Establishing Service Accounts
Upgrading vs. Side-by-Side Installation
Clustered Installation Considerations
Unattended Installations
Post-Upgrade Activity
Database Instances, Files, Locations, Filegroups, and Performance
Binary File Locations
Filegroups
Disk Planning Best Practices
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 3: MCTS SQL Server 2008 Exam 432 Configuring SQL Server 2008
Introduction
Instances vs. Default Instance
Instance Limitations
Performance Considerations
SQL Server Configuration Manager
Managing Services
Enabling FileStream
Managing Connections and Protocols
Shared Memory
Named Pipes
VIA
TCP/IP
Changing the TCP Port
Aliases
sp_configure and SQL Server Management Studio
Advanced Options
AWE
Setting the Maximum and Minimum Memory for SQL Server
Max Server Memory (MB)
Min Server Memory (MB)
Maximum Degree of Parallelism
Security Certifications
C2 Auditing
Common Criteria Compliance
New Features
Backup Compression Default
FileStream Access Level
Database Mail
Configuring Database Mail
Full-Text Indexing
Configuring Full-Text Indexing
Managing Full-Text Indexes
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 4: MCTS SQL Server 2008 Exam 432 Managing Security
Introduction
Principals
Roles
The “Principle of Least Privilege”
Users
Schemas
Users versus Logins
Authentication Mode
Permissions
Cross-Database Ownership Chaining
Object Permissions
Log-in Permissions (As Related to Roles)
Auditing
Change Data Capture (CDC)
Using DDL Triggers
The SQL Server Configuration Manager
Security and SQL Agent
Service Accounts and Permissions
Domain Service Accounts versus Local Service Accounts
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 5: MCTS SQL Server 2008 Exam 432 Managing Data Encryption
Introduction
Understanding Transparent Data Encryption
Requirements
Enabling TDE
How Data Is Encrypted
Encryption Keys
Key Management
Database Encryption Keys
Best Practices for Managing Database Keys
Cell- and Column-Level Encryption
EFS Encryption (Through the Operating System)
EFS in a Clustered Environment
Restoring Encrypted Backups to Another Server or Instance
Third-Party Encryption Tools
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 6: MCTS SQL Server 2008 Exam 432 Managing High Availability
Introduction
Defining High Availability
SQL High-Availability Options
Log Shipping
Mirroring
Clustering
Special Hardware Requirements
Special Software Requirements
Geo-Clustering
Replication
Recovery Model
Expandability
Hot Add CPU
Hot Add Memory
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 7: MCTS SQL Server 2008 Exam 432 Maintaining Your Database
Introduction
Understanding Data Collation
SQL Server Collations
Binary Collations
Using Collations
Collation Considerations for Backup and Restore
Maintaining Data Files
Implementing Data Compression
Row versus Page Compression
Estimating Space Savings Using sp_estimate_data_compression_savings
Using Sparse Columns
Maintaining Indexes
DBCC Explained
Using DBCC CHECKTABLE to Verify Table Integrity
Using the DBCC CHECKDB to Verify Database Integrity
Using the DBCC SHRINKFILE Option to Reclaim Database Space
Backing Up and Restoring Data
Understanding Database Recovery Models
Backup Types
Choosing a Database Backup Strategy
Restoring Databases
Performing Online Restore
Restoring Individual Pages
Performing Ongoing Maintenance
Using SQL Server Agent
Using Database Maintenance Plans
Policy-Based Management
Examples of Using Policy-Based Management
Using the Data Collector to Collect Performance Data
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 8: MCTS SQL Server 2008 Exam 432 ETL Techniques
Introduction
Understanding ETL
Bulk Copying Data
Using BCP
Using BCP Data File Types
Using Format Files
Using the BULK INSERT Statement
Recovery Model and Bulk Operations
Optimizing Bulk Load Performance
Distributed Queries
Understanding Fully Qualified Object Names
Enabling Ad Hoc Distributed Queries
Using the OPENROWSET Function
Querying Data with OPENROWSET
Modifying Data with OPENROWSET
Copying Data with OPENROWSET
Using OPENROWSET (BULK,…)
Using the OPENDATASOURCE Function
Using Linked Servers
Using the OPENQUERY Function
Using Distributed Transactions
SQL Server Integration Services
Creating SSIS Packages
Using the Copy Database Wizard
Using the Import and Export Wizard
Using Business Intelligence Development Studio
Using Package Configurations
Managing SSIS
Understanding SSIS Package Storage
Deploying SSIS Packages
Securing SSIS Packages
Using Package Protection Levels
MSDB Database Roles and SSIS Package Roles
Executing SSIS Packages
Logging Package Execution
Alternative ETL Solutions
Coding Solutions
Third-Party Solutions
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 9: MCTS SQL Server 2008 Exam 432 Managing Replication
Introduction
Replication Scenarios
Article
Publication
Subscription
Publisher
Distributor
Subscriber
Replication Types
Snapshot
Components
Transactional
Components
Updatable Subscription
Peer-to-Peer Replication
Merge
Components
Replication Configuration
Configuration of Distributor
Configuration of Publisher
Configuration of Subscriber(s)
Configuration of Peer-to-Peer Replication
Conflict Resolution
Conflict Resolution Mechanism in Peer-to-Peer Replication
DDL Replication
Security Considerations
Snapshot Agent
Connect to Publisher
Replication Performance
Monitoring
Replication Monitor
Tracer Tokens
Alerts
Performance Monitor
Replication Agents
Replication Distribution
Replication Logread
Replication Merge
Replication Snapshot
DMVs
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 10: MCTS SQL Server 2008 Exam 432 Monitoring and Troubleshooting
Introduction
Service Troubleshooting
Concurrency Issues
Agent Issues
Error Logs
Windows Event Log
SQL Server Log
SQL Server Profiler
Performance Monitor
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 11: MCTS SQL Server 2008 Exam 432 SQL Server XML Support
Introduction
Working with XML Data
Understanding XML Indexing
HTTP Endpoints
Http Endpoints Defined
Endpoint Can Interface to a Stored Procedure
How to Create the Endpoint
Web Services
XQuery Explained
XPath
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 12: MCTS SQL Server 2008 Exam 432 Service Broker
Introduction
The Queuing Concept Explained
Service Broker Defined
Message Types
Contracts
Queues
Services
Endpoints
Routes
Sending a Message
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 13: MCTS SQL Server 2008 Exam 432 Performance Tuning
Introduction
Tracing
Trace Templates
Trace Events
Trace Filters
Server-Side Tracing
Combining System Monitor and Profiler Traces
Replaying Traces
Using SQLDiag to Collect Performance Data
Locks, Blocking, and Deadlocks
Locking
Blocking
Deadlocks
Transaction Isolation Levels
Lock Escalation
Lock Compatibility
Detecting and Resolving Locking Problems
Guide to the DYNAMIC Management Views (DMVs)
Partitioning
Horizontal Partitioning
Vertical Partitioning
Filegroups
Selecting a Partition Key and Number of Partitions
Partition Function
Partition Scheme
Moving Data between Partitions
Performance Data Collection
Performance Data Collection Explained
Management Data Warehouse
Configuring MDW
Configuring Data Collection
Data Collection Caching
Management Data Warehouse Reports
Resource Governor
Resource Governor Concepts
Resource Pools
Workload Groups
Classification Function
Validate Configuration
Resource Governor Summary
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 14: MCTS SQL Server 2008 Exam 432 Implementing Objects
Introduction
Understanding DDL and DML Language Elements
Working with Tables and Views
Creating Tables
Creating User-Defined Data Types
Working with Constraints
Creating Indexes
Working with Full-Text Indexes
Viewing and Modifying Data
Creating Views
Creating Stored Procedures
Creating Functions
Creating Triggers
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Index
Appendix: The Real MCTS SQL Server 2008 Exam 432 Self Test
Appendix
Chapter 1: New Features in SQL Server 2008
Chapter 2: Installing SQL Server 2008
Chapter 3: Configuring SQL Server 2008
Chapter 4: Managing Security
Chapter 5: Managing Data Encryption
Chapter 6: Managing High Availability
Chapter 7: Maintaining Your Database
Chapter 8: ETL Techniques
Chapter 9: Managing Replication
Chapter 10: Monitoring and Troubleshooting
Chapter 11: SQL Server XML Support
Chapter 12: Service Broker
Chapter 13: Performance Tuning
Chapter 14: Implementing Objects
Nội dung
MaintainingYourDatabase•Chapter7 297 Performing Ongoing Maintenance SQL Server Agent is a service that can create multi step jobs, notification alerts, and notify operators by e-mail, pager or NET SEND command. SQL Server Agent service must be running for jobs and alerts to execute. It is also key to system functionality like replication, Policy-Based Management and data collector. The Database Maintenance Plan wizard allows sysadmins to create, modify, schedule and run customized maintenance plans. A Maintenance Plan is a sequence of ongoing maintenance tasks like rebuilding indexes, validate databases, and perform backup. Policy-Based Management is a new feature of SQL Server 2008 that allows you to create and apply policies to multiple target servers or database objects. A policy consists of a set of conditions that must be met by the object for it to be compliant with the policy. Objects that do not comply with the policy are reported to you when the policy is evaluated. Policies can be evaluated manually or automatically. This is known as “on demand”, “on change: prevent”, “on change: log only” and “on schedule” policy evaluation modes. These modes are used to check whether the target complies with the policy, and possibly prevent a change that will cause the object to become noncompliant. The “on change: prevent” and “on change: log only” policies are enforced using recursive DDL triggers. The “on schedule” evaluation is performed using SQL Server Agent. Performance Data Collection The Data Collector is a feature of SQL Server 2008 that allows you to systematically collect data from various sources and store it in a data warehouse. The Data Collector can be used to collect performance data, but it is not limited to this use. The Data Collector uses SQL Agent jobs to collect data, and SQL Agent must be running for the Data Collector to work. SQL Server Reporting Services reports are created on collected data. Built-in reports are available, or you can create custom reports. 298 Chapter7•MaintainingYourDatabase Exam Objectives Frequently Asked Questions Q: What happens to the database collation when a database is restored from backup to a server that has a different data collation? A: The database collation remains as it was on the source server. Q: How do I change collation settings at column and database level once they have been assigned? A: Use ALTER TABLE and ALTER DATABASE statements with the COLLATE clause. Unfortunately, there are many restrictions preventing this operation. Q: What happens when I join two tables, but the join keys have different collations? A: You will receive an error message similar to ‘Cannot resolve collation conflict between ‘Latin1_General_CS_AS’ and ‘Greek_CI_AS’ in equal to operation.’ Q: Which is more efficient: row-level compression or page-level compression? A: Page-level compression results in more efficient disk space usage as it enables row-level compression, prefix compression, and dictionary compression. However, page-level compression also results in higher performance overhead. Q: Can I create a column set on the entire table and update each row as an XML fragment? A: No, because column sets are defined on sparse columns and the primary key column cannot be marked as sparse. You must always have a primary key column in a table. Q: Is the Fill Factor of an index automatically maintained by SQL Server? A: No, the Fill Factor is only an initial setting. This is why you must rebuild your indexes as an ongoing task. Q: What is the overhead of Policy-Based Management on my SQL Server? A: Unless the policy is currently being evaluated, there is no overhead on SQL Server. Two exceptions are the “On Change: Prevent” and “On Change: Log MaintainingYourDatabase•Chapter7 299 Only” evaluation modes. These modes use DDL Triggers, which execute to perform a check every time an object in the policy’s target set is altered. This results in some overhead. Q: Can you manage earlier versions of SQL Server using Policy-Based Management? A: Yes, except not all settings are applicable to all versions of SQL Server. Q: When a SQL Server Agent job executes, what credentials are used? A: The credentials used are those of the SQL Server Agent service account, unless a proxy is explicitly configured or the statement is performing custom imper- sonation. Q: Is it better to create Maintenance Plans or individual SQL Server Agent jobs to perform my routine management and maintenance tasks? A: It is recommended that you use Maintenance Plans because they are easier to view and edit. Additionally, the Maintenance Plan Wizard will not let you misconfigure a task, which cannot be said for complicated homegrown Transact-SQL scripts. Q: Differential and log backups both record changes from the last full backup, so what is the difference between them? A: The difference between these backup types is in the way changes are backed up. The differential backup records all database extents that have changed since the last backup. When a differential backup is restored, all changes must be restored as there is no order or sequence of data changes. This makes the differential backup faster to restore than a log backup. Log backups record transactions in sequence. Replaying the log means redoing all transactions recorded in it. This is a time consuming operation, but it does allow you to roll forward to a point-in- time, provided all sequential log file backups are available. Q: I am missing a log file backup from the middle of a log sequence. Is it possible to restore all the other logs I have and roll the database forward, losing only the transactions recorded in the lost log? A: No, logs can only be restored in sequence. In this case, you can only roll the database forward to the point of the lost log. 300 Chapter7•MaintainingYourDatabase Q: How often should I back up the Master database? A: The Master database stores much of the server configuration information including security settings, database configuration, and logins. You should back it up regularly in the live environment. The exact frequency depends on your organization’s tolerance for loss of configuration data and how often this config- uration changes. Q: I have configured the performance Data Collector, but it has collected no data. Why? A: The most likely reason that the Data Collector is not collecting data is that the SQL Agent is not running. The Data Collector uses SQL Agent jobs to perform data collection. MaintainingYourDatabase•Chapter7 301 Self Test 1. You have a large centralized line of business database used by hundreds of users all around the world. One of the key tables is the Orders table. This table is frequently updated and frequently searched. A nonclustered index named IX_Orders_CustomerID exists on the Orders table, CustomerID column. Recently your company has experienced record sales, and many new customers have been added. You have received several user reports of degraded performance when trying to search for orders by a specific customer. After running some diagnostics, you are convinced that the reason for the performance degradation is index fragmentation. You wish to resolve the problem for your users, but, due to the 24-hour nature of your business, you are not allowed to take the index offline. Additionally, you wish to be able to interrupt reindexing operations without losing progress, in case the maintenance operation affects performance severely while it is running. What is the best way to resolve the problem while meeting your objectives? A. Run ALTER INDEX _Orders_CustomerID ON Orders.CustomerID REBUILD B. Run ALTER INDEX IX_Orders_CustomerID ON Orders.CustomerID REORGANIZE C. Run CREATE INDEX IX_Orders_CustomerID ON Orders. CustomerID WITH DROP EXISTING D. Run DBCC INDEXDEFRAG (LOBDatabase, “Orders”, IX_Orders_ CustomerID) 2. You have recently removed a lot of historical data from your SQL Server 2008 database named HR by archiving it to a different server. However, you notice that the disk space consumed by the database file remains unchanged and the .MDF file is taking up the majority of space on the drive. How can you decrease the size of the database file? A. Run DBCC CHECKDB (‘HR’, REPAIR_ALLOW_DATA_LOSS) B. Run DBCC SHRINKFILE (‘HR_Data’, TRUNCATEONLY) C. Run DBCC SHRINKFILE (‘HR_Data’, NOTRUNCATE) D. Use the Copy Database Wizard to copy the database, then delete the original database. Finally, rename the new database you have just copied to the same name as the original database. . task. Q: What is the overhead of Policy-Based Management on my SQL Server? A: Unless the policy is currently being evaluated, there is no overhead on SQL Server. Two exceptions are the “On Change:. recursive DDL triggers. The “on schedule” evaluation is performed using SQL Server Agent. Performance Data Collection The Data Collector is a feature of SQL Server 2008 that allows you to systematically. Transact -SQL scripts. Q: Differential and log backups both record changes from the last full backup, so what is the difference between them? A: The difference between these backup types is in the