You are on page 1of 50

Microsoft Learning Exam Cram Marathon

Exam 70-432 TS: Microsoft SQL Server 2008, Implementation and Maintenance
Patrick Pitre

Agenda
Microsoft SQL Server 2008 Exams and Certifications
Exam Roadmap

Certification Paths
Certification Roadmap

Target Audience Skills Being Measured

Deep-dive: Backup/Restore
Backup operations Restore operations Common Scenarios

o Exam Preparation
o Practice Questions o Additional Reading and Study Materials

o Test Taking Tips o Q&A

Choose Your Path

MCA

IT Certifications

MCM

MCITP & MCPD

MOS EXPERT

MCTS

AND/OR
MOS

MTA

MOS Certifications

MOS MASTER

SQL Server 2008 Exams and Certifications


Exam 70-432
TS: Microsoft SQL Server 2008, Installation and Maintenance
Exam 70-450 PRO: Designing, Optimizing and Maintaining a Database Infrastructure using Microsoft SQL Server 2008 Prerequisite: 70-432

Upgrade Path Exam: 70-453 Transition your MCITP SQL 2005 DBA to
TS: Microsoft SQL Server 2008, Development PRO: Designing Database Solutions and Data Access using Microsoft SQL Server 2008 Prerequisite: 70-433 TS: Microsoft SQL Server 2008, Business Intelligence Development and Maintenance. PRO: Designing a Business Intelligence Infrastructure Using Microsoft SQL Server 2008 Prerequisite: 70-448 Upgrade Path Exams available for all

Exam 70-433 Exam 70-451

Exam 70-448 Exam 70-452

SQL Server 2008 Certification Paths


http://bit.ly/9mEOTK

Where to Get It (MCTS MCA)


Microsoft Microsoft Technology Specialist and Professional Series certifications exams are administered by Prometric

More information about these Exam Cram sessions


All audio of the sessions will be downloadable
All content of the sessions will be downloadable Sessions run continuously all day today

Microsoft Learning representatives are available all day to answer certification questions via chat
Download promotional offers into your Virtual Backpack and book your exams soon!

Target Audience
Candidates should have one to two years of experience using SQL Server 2008 or two to three years of experience using a previous version of SQL Server. Candidates for this exam are IT professionals who have jobs in which database administration is their main area of responsibility, or they work in environments in which databases are central to their job roles. These job roles include the following:
IT generalists who work in environments in which SQL Server 2008 is part of an overall solution IT professionals who manage systems that run SQL Server 2008 IT professionals who work with third-party applications that are built on SQL Server 2008 Developers who build applications that use SQL Server 2008

Skills Being Measured 70-432


o Installing and Configuring SQL Server 2008 (10 percent) o Maintaining SQL Server Instances (13 percent) o Managing SQL Server Security (15 percent) o Maintaining a SQL Server Database (16 percent) o Performing Data Management Tasks (14 percent) o Monitoring and Troubleshooting SQL Server (13 percent)

o Optimizing SQL Server Performance (10 percent)


o Implementing High Availability (9 percent)

Installing and configuring SQL Server 2008


Installing SQL Server Service Accounts
Best practice Use separate user accounts (local or domain) for SQL Server and SQL Server Agent (to run Windows Services).

Authentication Modes
Windows (local Windows account or Active Directory/Domain account) Mixed Mode Windows and SQL Server authentication. Recommended: Dont use Mixed Mode unless you have to (e.g., dealing with legacy system).

Data Directories
Best practice: Use different disks to house data files (.mdf) and transaction logs (.ldf) files. Use different RAID types for performance. Transaction logs typically need highest disk-throughput. Set default locations for new database directories during installation. Can change later if necessary.

Collation Settings
Supports regional system locale. Affects ordering and case-sensitivity

Installing and configuring SQL Server 2008 (cont.)


SQL Instances
What is an instance?
Installation of SQL Server Database Engine*, that users/processes can connect to (e.g., with TCP/IP, Named Pipes, VIA, or Shared Memory).
Each SQL Server Instance runs as its own set of Windows Services, has distinct directory structure, registry structure, collation settings, security, etc. *Can include SQL Server Analysis Services and Reporting Services.

The Default Instance

Default instance name is MSSQLSERVER (including Windows Service name).


Can change default instance name. Set instance name during installation.

Named Instance

Allows you to run multiple instances of SQL Server on same machine, all accessible via TCP port 1433 (configurable), named pipes, etc.
Access via the computer hostname (or IP address if allowed) and Instance name.
If computer name is MySqlServer, and instance name is SQL2008, then access with MySqlServer\SQL2008.

Windows Service name will also show Instance name (same as above).

Installing and configuring SQL Server 2008 (cont.)


What else can I install? SQL Server Analysis Services (SSAS)
Microsoft Business Intelligence suite.

SQL Server Integration Services (SSIS)


Replaced Data Transformation Services (DTS) Includes Business Intelligence Development Studio (BIDS)
Drag and drop design surface for creating complex data transformation tasks (as well as SQL Admin tasks).

SQL Server Reporting Services (SSRS)


Full-suite of tools to build, deploy, and manage reports.
Robust API for custom programming.

Installing and configuring SQL Server 2008 (cont.)


Full-Text Search (FTS)
Allows users to run fuzzy queries against data; thesaures, stemming (break/breaking/breaker), and STOP words (to reduce noise in full text catalog.

Setup Full-Text catalogs first.


FREETEXT: less than typical WHERE clause. Stemming, word-breaking, thesaurus STOPLIST: Used when creating index to ignore specific words. Prevents full text index-bloat FREETEXTTABLE: Returns table with zero or more CONTAINS: Used in WHERE clause for fuzzy matches, proximity, or weighted words More powerful than LIKE T-SQL predicate. Like works on character patterns only.

Backup Wisdom
Every hard disk is guaranteed... To crash. - Unknown
A business that fails to backup, risks failure to be in business. - T.E Ronneberg Backup: Do it today, or pay tomorrow. Unknown SYSTEM ALERT: Backup Not Found: A)bort, R)etry, C)ry?

Blessed are the pessimists, for they have made backups. - Unknown
It's so logical and so simple. Fat is the backup fuel system. The role it plays in the body is that when there's no carbohydrate around, fat will become the primary energy fuel. That's pretty well known. Robert Atkins

Backup Basics
Four type of backups:
o Database backups
o Most common for most basic/straight-forward scenarios

o File backups
o Used to backup/recover individual files/filegroups. o Good for large database, where disk space is an issue.

o Partial backups
o o o o Can be used with Full or Differential NOT transaction logs. Works with filegroups. Back up Primary filegroup, read/write filegroups, plus specified files/filegroups Best for read-only filegroups, and you dont want to backup entire database
o Bandwidth, disk space, etc.

o Transaction Log backups


o Crucial for good disaster recovery plan. o Allows restore of all data since last t-log backup.

o Differential
o Can run in between Full backups o Used to keep backup size small, but each successive differential backup will be bigger than last,, until a full backup is performed again.

Recovery Models (Backup/Restore)


Full
Default recovery model; suitable for most OLTP and business scenarios.

Requires transaction log backups


Can recover data up to point of last t-log backup

Point-in-time restore (via transaction log backups)

Simple
Only recover changes up to last backup.
No transaction log backups. Not suitable for most production OLTP systems, as risk of data-loss is high.

Bulk-Logged
Requires transaction log backups. Minimal logging for recovery operations, so recovery can be faster.
Regular operations are still logged

Use with care set recovery model to bulk-logged, do the data-recovery, then set recovery model back to Full (or Simple).

Backup/Recovery
Transaction Log Backups (Full/Bulk-Logged recovery models only)
Essential for point-in-time data recovery.

Contains all the transactions that have occurred since the last full backup

Differential Backups
Only backs up changes in database since last full backup.

Smaller than Full backup, but will grow in size until next full backup.
Work well with large databases, when disk space or performance can become an issue.

Need a base backup (full backup) to recover fully. Can be used with transaction log backups.

Works with all three main backup types:


Database File Partial

Maintenance Plans
Can automate many DBA tasks, not only backups!
Execute T-SQL Statement, Index rebuild/reorg, update statistics. Management -> Maintenance Plans -> (right-click folder)

Maintenance Plan (using Wizard)


Wizard allows you to configure many backup options/tasks at once.

Maintenance Plan (no Wizard)


Designer surface, SSIS (SQL Server Integration Studio)
Can drag and drop objects

See Maintenance Plan examples on following slides

Example Maintenance Plan - Wizard


Lets setup two maintenance plans: one plan for full nightly backup, and one plan for transactions log backups every 4 hours. Management -> Maintenance Plans -> (right-click) -> New Maintenance Wizard

Create plan with specs below. Make sure folder exists. Check Verify backup integrity!

<-

Cleanup Task: Remove old backup files Sub-folders Delete old files every week

Example Maintenance Plan Wizard (cont.)


Once maintenance plan is created, can edit is SSIS design surface. Management -> Maintenance Plans -> (plan name) -> Double-click to open plan in designer surface.
Backup Database (Full) Task

Cleanup Task: Remove old backup files Include Sub-folders Delete old files every week (in this example)

Lets add an additional step: Cleanup Task

Example Maintenance Plan No Wizard


Use designer surface, drag and drop maintenance objects to design surface (similar to BIDS).
Toolbox of available tasks Drag object onto designer surface. Backup Database Task Details

Maintenance Cleanup Task Details

Common Backup/Recovery Scenarios - 1


Complete Backup - Full (daily/weekly/etc.) backups, with transaction log (t-log) backups
Provides granular, point-in-time restores of data.

Minimizes data loss can restore data up to most recent transaction log backup.
The more critical the data, the more often t-log backups should be scheduled.
Tolerance to pain and data loss. Decide, with LOB managers and stakeholders, how much data can be lost in a disaster situation. Every four (4) hours of data loss? Two (2) hours? One (1) hour?! Make sure you have sufficient disk storage for all your backup files!

Restore
Restore full backup first. If you have multiple transaction logs to be restored, make sure you restore and set the option RESTORE WITH NO RECOVERY option.
Or, in the restore wizard, make sure this option is checked. This will allow you restore subsequent tlogs, and restore more data closer to database disaster.

Note: if using Differential backups, restore last full backup, then any differential backups, then any t-log backups.

Common Backup/Recovery Scenarios - 2


Simple Recovery model
Appropriate for scenarios that dont require point-in-time recovery. Risks of data loss is high, since the only available data to restore is from last full/differential backup. Appropriate for databases that dont change often (mostly static tables, lookup tables, archive data, etc.)

Restore
Simple Recovery Model is easiest to restore, since only dealing with one or two backups (Full and Differential, respectively).
If you are using Full backups only, only need to restore one backup file (last full backup). If you are using Differential backups, need to restore base backup first (full backup), then restore the differential backup(s).

Use the WITH RECOVERY option, since no transaction logs to restore.

Transaction log management


Why is my transaction log (t-log) growing so big? What can I do? If you perform a full backup, and periodic transaction log backups, your transaction log should truncate (shrink) automatically.
Sometimes however, the t-log will continue to grow, despite your best efforts.

There are many factors that can delay log truncations:


No CHECKPOINT has happened since last log truncation Active Transaction(s)
E.g., long-running transaction, transaction is deferred

Replication
Undelivered transactions from Publisher to Subscriber.

Database Mirroring
Paused, or mirror database is significantly behind principle database.

Checkpoints
Write all dirty data and log pages to disk. Happens when a backup occurs.

Can set with the recovery interval

Transaction log management


There is a way to shrink the transaction log, but it should be used with caution! Backup the log, with truncate_only The use SHRINKFILE manually (with T-SQL)
Set new file size.

Using this method, you lose your ability to do point-in-time restores (but can save your hide in an emergency!) Once a transaction log completely fills up a disk, the risk of losing ALL of your data greatly increases.
Perform a FULL backup as soon as possible after a truncate_only command. Resume transaction log backups immediately.

Maintaining SQL Server Instances


SQL Agent and jobs SQL Server Agent service must be running for jobs ro tun
Agents user account (for Windows Service) must be a member of the SQL Server fixed server role sysadmin. Domain account is most flexible, but local user acceptable if jobs dont need remote server access.

Create and schedule jobs


Jobs can have multiple steps, can change order of steps Can run SSIS Packages, T-SQL Scripts, PowerShell, ActiveX script, Replication tools, Analysis Server commands, and more.

Schedule
Jobs can have multiple schedules.

Notifications
Email, Windows Event Log, Pager. Can automatically delete job upon completion (one-off jobs).

Alerts
E.g., Insufficient Permission (to run job), T-SQL syntax error, Fatal Errors, Can respond to condition, and notify as needed

Logging
Can log SQL job historyto table, output to file, or log in job history

Maintaining SQL Server instances (cont.)


SQL Operator Used by the SQL Server Agent to send notification from alerting and SQL Agent jobs.
SQL Server Agent -> Jobs -> (right-click -> Job Properties) -> Notifications

Contains user name, email, pager information, etc. Not used for server/instance/database security Can view notifications sent to user by SQL Agent jobs Can set Operator notification schedules Policies Powerful way to manage security and enforce standards
Create expressions to match conditions. Examples:

Ensure all views start with uv_


Can set default database Enforce password complexity Index creation

Maintaining SQL Server Security


Roles
Allows administrators ability to group and manage security and permissions for instance, server and databases roughly analogous to Active Directory (AD) or Windows groups.

Fixed, built-in Server Roles:


Includes dbcreator, sysadmin, diskadmin, public, and others. For managing configuration and maintenance tasks (backups, creating databases, security, etc.)

Database Roles
Database-specific roles (db_owner, db_datareader, db_datawriter, etc.) Security -> Logins -> (login Properties) -> User Mapping. New SQL Server login/user only has Public database role assigned by default.

Custom Roles T-SQL

Logins Can be user from Active Directory, or can be SQL-specific Authentication (SQL only account)
The sa account is a SQL Server login.

Can be assigned to server roles Can be assigned database roles Using Securables, can apply more fine-grained permissions to servers, endpoints, and logins. Logins can be disabled, have password policy, other controls similar to Windows or AD account.

Maintaining SQL Server Security


Object permissions
Allows administrators ability to group and manage security and permissions for instance, server and databases roughly analogous to Active Directory (AD) or Windows groups. Can secure almost any object: table, view, procedures, schemas, TVFs, and many others! In the example below, we create a new user (BGates), and give him permission to the AdventureWorks Sales schema. This creates a server login (Bgates), and database user (BillGates).

SQL Server Agent Proxies


Allows you to impersonate users in SQL Agent jobs, via Credentials (Security -> Credentials node in SSMS). 1. Create Credential (select local or domain user/group used for impersonation) 2. Create Proxy Use credential specified above, then choose Subsystem (CmdExec, PowerShell, Replication*, etc.) 3. Inside SQL Agent job step, select the corresponding subsystem you selected above in the Type dropdown. Now, that particular step will run under the identity you identified with Credential.

Maintaining SQL Server Security (cont.)


SQL Server security auditing Can be server (instance) or database-specific

Steps to happy auditing


Create Audit object (Security -> Audits -> (right-click) -> New Audit).
Give Audit Name, queue delay, destination (file, security or application log), Can force server shutdown if audit fails (if permissible)

Server Audit: (Security -> Server Audit Specifications (right-click) -> New Server Audit Specification)
Select Audit object created earlier. Audit Action Type (e.g., BACK_RESTORE_GROUP, FAILED_LOGIN_GROUP, SUCCESSFUL_LOGIN_GROUP, etc.) Object Class: Database, Object, Schema

Database Audit: (Databases -> <database_name> -> Security -> Database Audit Specification (right-click) -> New Database Audit
Same as Server Audit -> select Action Type, object, schema, etc. Database-specific Audit Action Types

Maintaining SQL Server Security (cont.)


How to create Audit and specification with T-SQL. Example below writes events to the Windows Security event log.

Enable new Audit (right click -> Enable) Create Audit Specification

Enable Audit Specification (right-click -> Enable)

Test by attempting to login with bad account Review Windows Security event log

Maintaining SQL Server Security (cont.)


sp_configure
Display and/or change configuration settings.

Admin trick: to find out if a change requires a SQL Service restart, and run SELECT * FROM sys.Configurations; if is_dynamic = 1 (yes/true), then no service restart required.

Performing Data Management Tasks


Import and Export data SQL Server Import and Export Wizard
Helpful for one off data import/export. Can import/export from Excel, CSV, Microsoft Access, Oracle, ODBC, and others. Can save as SSIS (SQL Server Integration Services) package, for later edit/scheduling via a Sql Server Agent job.
Can also run SSIS package from command line: bcp.exe

Bulk Insert
Set Recovery Model to bulk-logged to avoid filling up SQL transaction logs. Inserts comma-separated values from a text file into the AdventureWorks Sales.Customer table. Set/resets recovery model to BULK_LOGGED then back to FULL - to minimally log you bulk load of data (your transaction log will thank you!)

SSIS Package
Use BIDS to create everything from simple one-off jobs to complex ETL (Extract/Transform/Load) packages.

Performing Data Management Tasks


Partitioning Table and Index
Helpful for large tables or indexes can drastically increase performance, especially operations like loading data. Transparent to end-users (e.g., queries, view, functions, etc. all work the same)

CREATE_PARTITION_FUNCTION
RANGE (LEFT, RIGHT) FOR VALUES (<boundry_value>) SPLIT RANGE
Used to add a partition to the partition function Used to drop a partition, and move its data to an existing partition

MERGE RANGE

CREATE_PARTITION_SCHEME
Partitions use filegroups. This statement maps partitions to filegroups (physical files). Data moved to partitions based on user-defined criteria (e.g., create_date > 6-06-2011 or IDENTITY column (OrderId > 100000).

Performing Data Management Tasks


Indexing Clustered Indexes
One per table. If table has a PRIMARY KEY, then it will be used for a clustered index if none it set. Define logical order of the table. (note, not sort order). Clustered indexes actually hold their data (at the leaf level) Can use multiple columns to create index.

Non-clustered indexes
Multiple non-clustered indexes per table (999 in SQL Server 2008) Can use on Views. Good candidates are fields frequently included in a WHERE clause, as well as JOIN and GROUP BY statements.

Performance
Although indexes can speed up data access, there is a performance overhead associated with data edits, as indexes have to update as well. Particularly apparently when dealing with very large indexes.

Types of indexes
Filtered index
Allows a WHERE clause on index.

Spatial Geometric data (points, lines, polygons) Same rules apply as other index types. XML

Monitoring and Troubleshooting


Performance tuning Blocks, locks, and deadlocks, oh my!
Locking is normal part of database engine function. Ensure transactions are atomic and isolated.

Blocking happens when a transaction is preventing another transaction from running.


Some blocking is normal, but excessive blocking can severely hinder performance. Essential for maintaining concurrency. Block is NOT deadlocking!

Deadlocks

Severe blocking can lead to deadlocks: where two transactions are competing for the same resource; a vicious circle, as both tasks will wait endlessly for each other.
Multiple way to find deadlocks:
Right click database -> Reports -> Standard Reports -> All Blocking Transactions T-SQL/DMV (Dynamic Management Views)

Monitoring and Troubleshooting (cont.)


Activity Monitor Ctrl-Alt-A
Shows a variety of useful information.

Monitoring and Troubleshooting (cont.)


Dynamic Management Views (DMVs)
Introduced in SQL 2005. Used to diagnosis problems, as well as for performance tuning. Robust information about the current state of the server.

Server-scoped: stored in Master database. Database-scoped: specific to each database


Dont reinvent the wheel! DMVs work best when joined to other DMVs, and they get complex quick!
Use online resources to find useful DMVs you can use/alter. See example below (from http://sqlserverperformance.wordpress.com/2008/01/21/five-dmv-queries-that-will-makeyou-a-superhero/), ran against a SharePoint 2007 server.

Monitoring and Troubleshooting (cont.)


Logging/viewing of events
Windows Event Logs (start -> run -> type in eventvwr, press enter) SQL Server Logs
<database instance> -> Management -> SQL Server Logs (Current, Archive, etc.) Can view info about database engine, SQL Agent, database mail, and even the Windows event log! View history of SQL Agent job execution (right-click job, -> View History) Error Logs: SQL Server Agent -> Error Logs (Current, Archive, etc.) SQL Server Agent troubleshooting

SQL Agent Jobs


Optimize SQL Server performance


Running SQL Traces
SQL Server Profiler. Save trace to file or database table.

Database Engine Tuning Advisor (DTA)


Learn how DTA and SQL Profiler work together Workloads Analyze workload from a captured trace

Dynamic Management Views


Useful for gathering system information
Located in the sys schema Server-scoped: Stored in Master database
Memory (e.g., sys.physical_memory_in_bytes)

Threads (e.g. sys.max_workers_thread)

Database scoped: Specific to each database


Disk Space (e.g., sys. dm_db_file_space_usage) Query stats (e.g. sys.dm_exec_query_stats)

Optimize SQL Server performance (cont.)


Resource Governor Monitor and control CPU and memory workloads.
<server instance> -> Management -> Resource Governor A picture says a thousand words!

Optimize SQL Server performance (cont.)


Data Collection Performance Studio New in SQL 2008. Requires the SQL Server Agent to be running. Database report, on steroids! First, must setup data warehouse to house data.
Configure Management Data Warehouse (Management -> Data Collection)
Create or upgrade a management data warehouse

Second, run wizard again, and choose Set up data collection Be prepared for fast data growth can be upwards of 500 MB/day in some cases. 3-4 % potential performance overhead View reports of collected data: Management -> Data Collection -> (right-click) -> Reports -> Management Data Warehouse ->
Server Activity History Disk Usage Summary Query Statistics History

Optimize SQL Server performance (cont.)


Performance Studio Server Activity History

Implementing High Availability


Replication Publisher/Subscriber model. Articles: Tables, views, stored procedures, user defined functions

Filter: Use WHERE clause in deciding what data to replicate


Transactional
Good for high-availability, or offloading queries. Database changes are streamed from the publisher to the subscriber automatically.

Merge
Good for mobile/remote databases that need to merge changes when connected.
SQL Compact Edition

Snapshot
Can provide initial data for merge or transactional replication. Can also be used to refresh the data. Can use as basis for reports (to minimize server performance impact of reporting-style queries)

Push/Pull
Snapshot Agent
Manages the snapshot of published DB objects, including generating the file, and synchronization.

Distribution Agent
Moves the snapshots and transactions to the Subscribers.

How Microsoft does it!


http://msdn.microsoft.com/en-us/library/dd263442.aspx

Implementing High Availability (cont.)


Mirroring

Principle (Standard or Enterprise edition) Witness (Standard, Enterprise, Workgroup, Express) Server must first be configured (security, TCP port, etc.). Database only. Operating Mode
High-performance (asynchronous)
Commit at principle first, then witness if successful

High-safety (synchronous)
Commit changes on both servers

High safety with automatic failover (synchronous)


Commit changes on both servers Witness control failover if principle goes down

Failover Clustering (Standard or Enterprise edition) Nodes: Each SQL instance is a node. Up to 16 nodes. Entire instance (Mirroring is per-database only). Single copy of database in shared storage array. Failback policy
Can fall back immediately or during scheduled time.

Upon failover, transactions are rolled forward, incomplete transactions are rolled back, etc. Encryption can use encrypted connections, via certificates.

Implementing High Availability (cont.)


Log Shipping Transaction logs can be sent to separate server, for a warm standby.
Recovery model needs to be Full or bulk-logged (with NO RECOVERY)

Requires SQL Server Agent be running.


Primary, Secondary, optional Monitoring server. Full backup is taken on Primary server, shipped to Secondary server. Additional transaction logs are shipped over, as needed. Can also be used as a reporting solution (to offload performance hits on the primary server for potentially complex reporting queries).

Test Taking Tips


Study a variety of material
Nothing beats hands-on experience

Study from at least two (or more) books


Run through the examples

Eliminate answers you know are not correct Mark to review, and come back later Manage your time Dont Panic! Review all your answers at the end

Additional Reading and Study Materials


Books MCTS Self-Paced Training Kit (Exam 70-432) Microsoft Press

Microsoft SQL Server 2008 Management and Administration


Ross Mistry - SAMS Other resources: To find more prep materials for your exam visit: http://www.microsoft.com/learning/en/us/Exam.aspx?ID=70-432&locale=en-us Schedule your next exam: https://www.prometric.com/Microsoft/default.htm Review the Entire SQL Certification Path http://www.microsoft.com/learning/en/us/certification/cert-sql-server.aspx

Q&A

You might also like