Microsoft SQL Server Administration Using MS SQL Server 2008
Microsoft SQL Server Administration Using MS SQL Server 2008
Microsoft SQL Server Administration Using MS SQL Server 2008
www.certifiednetworks.com
Logistics
Class Days: 3
Class Hours: 9-5
Notes/Handouts
Demos
Class website
Recommended Reading
Microsoft SQL Server(TM) 2005 Administrator's
Pocket Consultant
(Pro-Administrator's Pocket Consultant)
Microsoft Press
Module 1: Overview
Course Outline
Lab Setup
Definitions
Tools
What is SQL Server
SQL Language Basics
SQL Server Network Integration
Module 1: Overview
Module 2: Installation
Module 3: Objects and Securables
Module 4: Security And Principals
Lab Setup
Windows 2003 Server
SQL Server 2008
Standard, or Enterprise
Computer Names
IP Addresses
Definitions
Transact SQL
DBA
Server
Client
Concurrency/Locks
Login
User
Role
Database
SQL SMO(Formerly
DMO)
SQL Instance
Principal
Securable
Tools
Profiler
SELECT
INSERT
UPDATE
DELETE
DNS
Windows Domain/Active Directory
Firewalls
Lab 1A Tools
In this instructor led lab, you will:
Preview SQL Management Studio
Preview Database Engine Tuning Advisor
Preview Profiler
Module 2: Installation
Software Requirements
Hardware Requirements
SQL Server Versions
Licensing
Capacity Planning
SQL Services
Installation
Software Requirements
Windows Server
2000
2003 or 2008
Windows XP (Developer)
Windows CE
Hardware Requirements
Install Type Dependent
Express
192 MB RAM
Standard/Enterprise
512MB RAM
Enterprise
Standard
Developer
Workgroup
Express
Windows Mobile
Licensing
Per Processor
Per Server plus Device CALS
Per Server plus User CALS
SQL Server 2008 Express is free
Capacity Planning
Drive Space
CPU
Memory
I/O Subsystem
I/O Subsystem
RAID 0, 1, 5 or 10
Logical Drive Structure
Physical Drive Structure
Considerations:
Performance
Ease and Cost of Management
Disaster Planning
SQL Services
Service Names:
SQL Server (MSSQLServer)
SQL Server Agent (MSSQLServer)
SQL Server Browser
SQL Traffic director, allows Dedicated Admin Connection
(DAC)
Starting/Stopping
Service Accounts
LocalSystem
Local Account
Domain Account
Automatic Startup
Installation
Options
Server
Instance
Client Tools Only
Administrative Rights
Instances
Object Definition
Creating Objects
Altering Objects
Dropping Objects
MetaData
Object Permissions
What is an Object?
Type Of Objects:
Table
View
Stored Procedure
Trigger
DataType
Function (UDF)
Index
Constraint
Synonyms
Allows an alias for a securable
New CREATE SYNONYM syntax
Creating Objects
CREATE Statement
Example:
CREATE TABLE Customers(
CustomerID int identity,
CustomerEmail varchar(50)
)
Altering Objects
ALTER Statement
Example:
ALTER TABLE Customers
ADD CustomerPhone varchar(40)
Dropping Objects
DROP Statement
Example:
DROP TABLE Customers
Getting Metadata
Information Schema
Sysobjects table
Sp_helptext
Setting Permissions
GRANT Statement
Example:
GRANT SELECT
ON Customers
TO Public
Levels of Security
Login Server Level
User Database Level
Object Permissions to Access Objects
Application Security
Network Access
Encryption
Single Sign-On
Access all resources after logging in only
once
Auditing
Active Directory
Extension of the Domain Model
Leverages DNS Name Resolution
Better Security Protocols
Better Fault Tolerance
More Extensible
Group Policy
Logins
Types:
Windows (Integrated)
SQL (Standard)
Tools
SQL Management Studio
Scripts
Users
Tools:
SQL Management Studio
Scripts
Roles
Role Is A Group of users
Purpose Ease Permission Management
Role Types:
Standard
Application Role
Tools:
SQL Management Studio
Scripts
Permissions
User Defined:
Action
Object Access
Object Execution
Tools:
SQL Management Studio
Scripts
Module 5: Backup
Types:
Full
Differential
Log
COPY_ONLY option
Does not disturb normal backups, truncate logs, or
reset any flags
Use of Filegroups
Backup Statement
Example:
BACKUP DATABASE Lab3A
To Disk=c:\Lab3A.bak
WITH INIT, BLOCKSIZE=2048
Backup Options
Backup Requirements
System Databases:
Master New Logins, change password
MSDB Modifying or creating jobs
User Databases:
Whenever data loss is unacceptable
At a rate when the cost(cash, downtime) of
restore is unacceptable
Backup Devices
Device = File
Permanent object you can reference by
name
Example:
BACKUP DATABASE Lab3A
TO DailyBackup
Tape Backup
Must be attached locally to the SQL
Server
Some syntax is unique to tape media
Must be recognized by Windows Backup
as a SCSI tape device
WITH No_Truncate
Emergency use when data file not available
Backup Strategies
Weekly Full Backup
Nightly Full Backup
Variations of above with Differential and
Log Backups
Best Practices
Use Automation
Test Your Backups
Use Notification
Use COPY_ONLY option as needed
Understand the Business
Keep Management Informed
Module 6: Restore
Restore Process
Always backup the log first!
Full
Differential
Log
Recovery
Saving Space
Maintain the log file
Compress your backup files
Restoring Master
Place server into single user mode
Perform Restore
Restart Server
Best Practices
Web Technologies
Allow connection to SQL Server through
HTTP
Used for logging, collecting data,
reporting, data transfer and admin
functions
Examples:
ASP, ASP.Net, Perl, CGI, Cold Fusion, JSP,
Java
Communication Process
SQL Injection
Malicious users leverage web input
against SQL Server
Examples:
Running server level commands
Changing the where clauseOR 1=1
Running DDL Commands
Reading ODBC Errors for data discovery
ASP Example
ASP.Net Example
Email Notification
Allows asynchronous communication with SQL Server
Numerous techniques:
Database Mail
New to SQL 2005
Easy to use smtp mail provider, easy setup
CDONTS.Newmail
Provided as a .dll file with Windows 2000
Com Object
CDO.Message
Provide with XP/Windows 2003
Com Object
SQLMail
MAPI Client
Must be setup during a full moon
CDONTS Object
CDO Object
Database Mail
Requirements
SQLServerAgent service must be running
Permissions on network or local resources
Automation Examples
Nightly backup
Nightly data transfer
Hourly generation of web pages
Detection of server problems:
Log 95% full
Backup Log
Email Notification
Automation Components
Job
Collection of steps, each step performing work
Operator
Pointer to email account in Database Mail or SQL
Mail
Alerts
Connection between a detected problem and a
job/operator
Jobs
Created with gui or with sp_add_job
May be scheduled
Comprised of Steps:
Transact SQL
Operating System Commands
ActiveX (VBScript/Javascript)
Other (Replication, SSIS, Analysis Services)
Retain history
Might have success/failure workflow
Can target multiple servers
Operators
An alias to a native email address of SQL Mail or
Database Mail
Net Send address also supported
Operator Addresses
Email business hours email address
Pager after hours email address
Net send
Failsafe Operator
Defining an Operator
Alerts
Alert types
SQL Server Error
SQL Server Performance Condition
WMI Query
Defining An Alert
Proxies
Allow job steps to run with a different windows
login
Data Transfer
Movement of data between systems
One of the most common DBA functions
SSIS
Import/Export Wizard
Visual Studio Project
BCP
Command line utility
Examples:
Bcp northwind..products out
c:\nwind.csv w t, -r/n T
Bcp select * from products
queryout c:\nwind.txt c t~ -r/n
Usa -P
Backup/Restore
Simply compress, then transfer the backup
file to the destination
Clean up sysusers table after restore
Distributed queries
Openquery/Openrowset/OpenXML
SELECT INTO
INSERT/SELECT
Linked Servers
Query Analyzer
Controlling saved results
Output to text file
Reading from different providers
Bulk Insert
Definitions
Automatic transfer of data between
locations
Replication Types
Transactional
Only changes are copied across
Most efficient
Merge
Two sources of read/write data
Most dangerous
Snapshot
Data is removed, then re-created on a
schedule
Replication Models
Central publisher/Distributer
Central Subscriber/Multiple Publisher
Multiple Publisher/Subscriber
Setup Tips
Ensure box servers are logged in with a
domain account
Ensure the domain account is an admin on
both boxes
Ensure the domain account can map to c$
Ensure the domain account can run
queries against the other server