Microsoft SQL Server 2008 Administration
Microsoft SQL Server 2008 Administration
• 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)
– SQL Server Integration Services
• SQLIS.com
– SQL Server Fulltext Search
– SQL Server Analysis Services
– SQL Server Reporting Services
• Starting/Stopping
Service Accounts
• LocalSystem
• Local Account
• Domain Account
• Automatic Startup
Installation
• Options
– Server
– Instance
– Client Tools Only
• Administrative Rights
• Instances
Online Demonstration: Installing an
SQL Server instance
Module 3: Managing Objects
• 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
• 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
Lab 3A: Creating Objects
Lab 3B: Altering Objects
Module 4: Security and Principals
Surface Area Configuration
• Best practice – reduce the “surface area” exposure of
your system to minimum
• Off By Default
– Microsoft .NET Framework,
– SQL Service Broker Network Connectivity, and
– HTTP connectivity in Analysis Services
– Xp_cmdshell
– Ad Hoc Remote Query
– Database Mail
– Native XML Web Service
• See Surface Area Configuration Tool
Levels of Security
• Login – Server Level
• User – Database Level
• Object – Permissions to Access Objects
• Application Security
• Network Access
• Encryption
Windows Workgroup Model
• Distributed Accounts
– Each machine has locally maintained user
and group database
• Windows Server Not Required
Windows Domain Model
• Centralized Accounts
– Active Directory is a single source for users
and groups
• 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
Lab 4A: Creating Accounts
Lab 4B: Creating Users and
Groups
Lab 4C: Permissions
Module 5: Backup
Reasons for Data Loss
• Accidental Update
• Hardware Failure
• Improper Application Design
– Transactions Not Used
• Other User Error
• Intentional Distruction
– Hackers
– Viruses
SQL Server Backup
• Online Backup
– Users can access data during backup
• Types:
– Full
– Differential
– Log
• COPY_ONLY option
– Does not disturb normal backups, truncate logs, or
reset any flags
• Use of Filegroups
Increasing Backup Performance
• Set appropriate BLOCKSIZE parameter
– -2048 good for cdrom stored backups
– With default setting, restore uses buffered io
which is more flexible and slower
• Options:
– Full
– Bulk_Logged
– Simple
• Example:
BACKUP DATABASE Lab3A
TO DailyBackup
Tape Backup
• Must be attached locally to the SQL
Server
• WITH No_Truncate
– Emergency use when data file not available
• Full
• Differential
• Log
• Recovery
Saving Space
• Maintain the log file
• Compress your backup files
Log Restore Options
• Stopping at a certain time
• Perform Restore
• Restart Server
Restoring Master with No Backup
• Rebuilm.exe utility creates brand new
master, model, msdb
• 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
Defining a Job Step
Operators
• An alias to a native email address of SQL Mail or
Database Mail
• 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
• Windows eventlog MUST trigger response
• Alert response is defined by admins
– Execute Job
– Send Notification
Defining An Alert
Proxies
• Allow job steps to run with a different windows
login
Lab 8A: Automation and Job
Scheduling
Module 9: Data Transfer
Data Transfer
• Movement of data between systems
• One of the most common DBA functions
Data Transfer Examples
• Nightly download of sales data from all
stores
• Quarterly catalog update for website
• Order fulfillment
– Hourly transfer of order information to
fulfillment center
– Hourly gathering of ship tracking information
• Movement of web data into accounting
system
Data Transfer Techniques
• SSIS and Import-Export Wizard
• Legacy DTS Package Support
• BCP.EXE command line utility
• Backup/Restore
• Distributed Queries
• Saving results from query analyzer
• Web Page download
• Bulk Insert Statement
• Detach/Re-attach database files
• Log Shipping
• Select/Insert
SSIS
• Import/Export Wizard
• Examples:
Bcp northwind..products out
c:\nwind.csv –w –t, -r/n –T
• Linked Servers
Query Analyzer
• Controlling saved results
• 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
Lab 13A: Replication