Professional Documents
Culture Documents
Specialized Editions
• Developer (x86, x64, IA64)
• Workgroup (x86, x64)
• Web (x86, x64)
• Express (x86, x64)
• Compact (x86)
Specialized Editions
Number of 50 16 16
Instances
Memory O.S. maximum O.S. maximum 4GB O.S. maximum 1GB
Database
snapshots
Log shipping
Number of 16 2
clustered nodes
Database Full Single-thread Witness only Witness only Witness only
mirroring
Replication Full Full Subscriber only Subscriber only Subscriber only
Support
Data Compression
Transparent Data
Encryption
Pricing and Licensing SQL Server
2008
CAL $8,487 for server $885 for server license $730 for server license Not available
license plus $162 per plus $162 per CAL plus $162 per CAL
CAL
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
SQL 2008 Is About…
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
What’s New in SQL Server 2008
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Performance Improvements
• Compression Enhancements:
– Backup compression
• Are your backups taking up too much space?
– Log Stream compression
• Are you using database mirroring? If so, log stream
compression can offer significantly better performance
– Data compression
• Do you have a lot of data that is similar or bloated?
• Easy to use: BACKUP DATABASE … WITH
COMPRESSION
Performance Improvements
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Security Improvements
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Management Improvements
• New Feature:
– Policy-Based Management
• DBAs can set policies that cover everything from
naming conventions to CLT integration
• One of the most exciting new features for DBAs
Management Improvements
• New Feature:
– SQL Server Audit
• Allows customizing what you want audited
• Allows for auditing at server and database level
– SELECT, INSERT, UPDATE, DELETE, EXEC
– DBCC
– Login/logout attempts
– State changes
• Scripts can be generated from audits
Management Improvements
• New Feature:
– Change Data Capture (CDC)
• Allows you to record changes to data into another table
without triggers
– INSERT, UPDATE and DELETE
• Perfect for applications that update external databases
• Example: you need to synchronize two 200GB
databases nightly in a one-hour window
Management Improvements
• New Feature:
– Data Profiling Task
• New SSIS Task allows DBAs to profile for things like:
– Number of rows
– Number of unique values
– Percentage of NULL values in column
– Duplicate values in potentially key columns
Management Improvements
• New Feature:
– Extended Events (Xevents)
• Capture, filter, and act upon events generated both by
SQL Server, the operating system, and other
applications
• Can trace events at any level
• Can choose aggregated data or event details
Management Improvements
• Enhancements
– Central Management Servers & Server Groups
• DBAs can now designate one SQL Server a Central
Management Server and create a Server Group
– Queries can be executed on the servers in the server group
– Policies can be evaluated against the group
– Changes made in Object Explorer can be propagated
– Windows authentication required
In this video
DBAs
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Availability Enhancements
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
What’s New in SQL Server 2008
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
T-SQL Improvements
• XML enhancements
– Better and easier schema validation
– Better XQuery support
• Use of “let” clause to assign values
– Full xs:dateTime support
T-SQL Improvements
• FILESTREAM
– Allows DBAs and Developers to store documents
as part of the operating system yet to be able to
access those as part of the database
• COMMIT/ROLLBACK aware
• Uses new VARBINARY(MAX) FILESTREAM storage type
• Users can use regular SELECT, INSERT, UPDATE, and
DELETE statements to query and modify FILESTREAM
data
In this video
DBAs
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Datatypes and Geospatial
• HierarchyId
– Used to represent the position in a hierarchy
– Has it’s own functions to work with hierarchical
data
• GetAncestor()
• IsDescendant()
Geospatial Datatypes
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
The Debugger is finally in SSMS
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
What’s New in SQL Server 2008
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
SSIS Enhancements
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Reporting Services
Improvements
Business Intelligence
Developers
• Overview of • T-SQL • SSIS
new features Improvements • SSRS
and how it • Datatypes • SSAS
relates to • Geospatial
DBAs
• Debugging
• Performance
• Security
• Management
• Availability
Analysis Services
• Star JOINs
• MERGE statement
• Various enhancements
Deprecated and Discontinued in
SQL Server 2008
3. 32-bit or 64-bit?
– Did you know? Windows Server 2008 will be
the last 32-bit server from Microsoft
– The advantage of 64-bit architectures are that
you can address more physical memory
– In a 32-bit system with 16GB of physical RAM,
you can only directly address 4GB
• You can still use the rest but it uses Address
Windowing Extensions (AWE) to “map” to the
memory whereas 64-bit can address the memory
directly
Things You Need to Know Before
Installing SQL Server 2008
3. 32-bit or 64-bit?
– 64-bit supports larger numbers of processors
and more linear scalability per processor
– This may mean lower Total Cost of Ownership
(TCO) since you can “do more with less
hardware”
Things You Need to Know Before
Installing SQL Server 2008
5. Windows Authentication
– PROs:
• No passwords are stored in SQL Server or sent across the
network
• Centralized management of users and groups (in Active
Directory)
– CONs
• The SQL Server DBA is no longer in control of security
– Windows admins can now add/remove users from Windows
groups thus elevating/denying privileges in SQL Server
• Non-Windows machines have trouble logging in
• Anyone without a Windows account cannot use SQL
Server
Things You Need to Know Before
Installing SQL Server 2008
5. Mixed Mode
– PROs:
• Best of Windows Authentication mode
• SQL Server can control security more granularly
– CONs
• Passwords are passed across network
– Can be encrypted
• Microsoft says this is less secure
Things You Need to Know Before
Installing SQL Server 2008
5. Account Provisioning
– Depending on what features you install, you must
determine how they log in
– The following features are require a service account:
• SQL Server Database Engine
• SQL Server Agent
• SQL Server Browser
• SQL Server Analysis Services *
• SQL Server Reporting Services *
• SQL Server Full-text Daemon Launcher *
• SQL Server Integration Services *
6. Default locations:
Item Path Can Be
Changed?
SQL Server \Program Files\Microsoft SQL Server\MSSQL10.<INSTANCE_ID>\ Yes
Program Files
Reporting Services \Program Files\Microsoft SQL Server\MSRSL10.<INSTANCE_ID>\ Yes
Program Files
Analysis Services \Program Files\Microsoft SQL Server\MSASL10.<INSTANCE_ID>\ Yes
Program Files
SQL Server Data <INSTALL DIRECTORY>\Data\ Yes
Files
SQL Server Backups <INSTALL DIRECTORY>\Backup\ Yes
7. Collation defines:
– Sort order
• Does “A” sort before “a”?
– Whether accents, binary, and case-sensitivity
matter
• Are “Pérez” and “perez” the same?
– The characters available in a column
• More on this later...
Things You Need to Know Before
Installing SQL Server 2008
• Instance Miscellany:
– Enterprise Edition: up to 50 instances
– Other editions: up to 16 instances
Instances
• Licensing
– All editions now allow CPU license to cover
“unlimited instances per operating environment”
Things to Know After You Install
SQL Server 2008
• Cannot be requested
– Released when MSFT decides
Service Packs and Hotfixes
• Service Packs
– Usually rollup every COD, OD, CU and GDR since
the last service pack
– Service packs are cumulative
• SP3 includes all of SP1 and SP2
– Often include new features
Service Packs and Hotfixes
• ISM model:
Service Packs and Hotfixes
• Build Numbers
– To determine the service pack level, you can check
the build number
– To determine hotfix, COD, OD, et al, sometimes
you need to look at the file version
• Build numbers are built around initial
release and service packs
Service Packs and Hotfixes
SELECT
SERVERPROPERTY('productversion'),
SERVERPROPERTY ('productlevel'),
SERVERPROPERTY ('edition')
Service Packs and Hotfixes
• Be wary
– COD are least tested
– Service Packs are most tested
– Install what you need
– Use a test box
Final Thoughts
• Be prepared
– Often, removing a hotfix/service pack/etc requires
an uninstall/reinstall
– Be sure you back everything up before installing
– Be prepared to support multiple versions/builds
Things to Know Before You Install
SQL Server 2008
• Management Tools
– SQL Server Management Studio (SSMS)
– SQL Server Configuration Manager
– sqlcmd
– Import and Export Data
– PowerShell
• Development Tools
– SSMS
– Business Intelligence Development Studio
– Visual Studio 2008
• Performance Tools
– SQL Profiler
– Database Engine Tuning Advisor
• Documentation and Tutorials
– Books Online (BOL)
What Is Installed
• sqlcmd.exe
– Command line query and script execution engine
– Can do most of what SSMS can do
– Powerful scripting capabilities
What Is Installed
• Next steps
– Understand the configuration parameters
– Check your database compatibility
– Review “Suggested Changes After Upgrade” video
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
This Chapter
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
An Overview of What Is Installed
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration
• Shared Memory
– Connections and data are not transferred across IP
stack; done in memory
– Clearly this only works when the client and server
are on the same machine
– For remote connections, must use one of the
other network protocols
Configuration: Network Protocols
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration: Memory, CPU
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Configuration
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo • Demo
A Look at the Tools and Configuring
SQL Server 2008
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
How to Change Configuration
Settings
How to Change Configuration
Settings
• Tips
– Have a “backup” or “back out” plan
– Understand that SQL Server will often clear out
portions of its memory after configuration
changes
• This can have severe short-term impact!
Configuration
Configuration
The Tools
Overview
• Overview • An • Configuring
of Chapter Overview SQL Server
of the Tools 2008
• Demo
Databases in SQL Server 2008
Management
Overview
Management
Overview
BEGIN TRAN
INSERT PayrollProcessingHistory
VALUES (‘Whigham’, ‘2009-04-01’, @PayAmount)
INSERT ChecksToWrite
VALUES (@ProcessingHistoryId , @PayAmount)
COMMIT TRAN
SQL Server Databases
Management
Overview
Management
Overview
Management
Overview
Management
Overview
* More information can be found in our SQL Server 2008 Analysis Services course
In the next video…
Management
Overview
Management
Overview
• Performance
– The more disks, the faster performance
– SQL Server can read two files on two separate
disks in parallel
• Can nearly double read and write access
Why should I use multiple files?
Management
Overview
Management
Overview
• Autogrowth parameters:
– Grow the file by a percentage of current size or a
fixed amount (in MB)
– Set maximum size
• Hint: Always set a maximum size
– Do not let the file grow until it fills up the disk
Creating Databases
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
SELECT *
FROM Parent p JOIN Child c
ON p.DateTimeKey = c.DateTimeKey
Database Configuration
• Parameterization continued…
– When parameterization is SIMPLE and SQL Server
recognizes a query that it thinks will be used in the
exact same way but with different SARGs (Search
ARGuments), it will attempt to create a reusable
execution plan
• Previously called “auto-parameterization”
Database Configuration
SQL Server recognizes that this query will likely have multiple variations
SQL Server creates a reusable, parameterized query plan that satisfies both
queries
Database Configuration
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
Management
Overview
• Let’s do a demo!
An Overview of Indexes and
Partitioning
Management
Overview
Management
Overview
Management
Overview
• Let’s do a demo!
Managing Database Files
Management
Overview
• Let’s demo!
Managing Database Files
Management
Overview
DBCC SHRINKDATABASE
( database_name [ , target_percent ]
[ , { NOTRUNCATE | TRUNCATEONLY } ]
)
Shrinking a Database
• NOTRUNCATE
– Compress pages to “front” of file
– Does not release freed space to OS
– Only available in T-SQL
• TRUNCATEONLY
– Does not compress the pages to the front of the file
– Releases freed space after the “last” page to the OS
– Default in SSMS
Shrinking a Database
-- TRUNCATEONLY:
DBCC SHRINKDATABASE(N'LearnItFirst.com')
-- NOTRUNCATE:
DBCC SHRINKDATABASE(N'LearnItFirst.com',
NOTRUNCATE)
Shrinking a Database
• EMPTYFILE
– Moves pages to another file in the file group
• target_size
– Cannot compress data
– Defaults to MB
– If not specified, uses the creation size
Shrinking a Database
• Let’s demo!
Suggested Changes After the
Upgrade
Management
Overview
• Remember that:
– Service packs are the most-tested
– Cumulative Updates are the next-most-tested
– Critical Updates are the least-tested
• You don’t have to install the most recent
updates
– Unless there is a specific security issue
After the Upgrade
• Let’s demo!
Suggested Changes After the
Upgrade
Management
Overview
Management
Overview
Management
Overview
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Chapter Overview
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server Security
• Physical Machine
– Who has access to the actual machine?
• Hard drives in many servers can easily be removed
– Recommendations to reduce attack surface area:
• Server in a locked room with access limited to systems
admins only
SQL Server Security
• Operating System
– Should you run other software on this machine?
• Internet Information Server (IIS), Exchange, SharePoint
– Which users have logins to the server?
• If they can login to the server, can they make a file copy
of SQL Server databases?
– Recommendations to reduce attack surface area:
• The more critical/sensitive/large the database(s), the
more likely you need a dedicated machine
• Only allow system administrators and DBAs to login to
the operating system
SQL Server Security
• Network
– By changing default network settings you can
reduce the surface area
• Changing default instance TCP port from 1433 to
another value
– Recommendations to reduce attack surface area:
• Place your web SQL Server behind a firewall to prevent
remote access (if possible)
• Consider allowing local-only connections for
applications installed on the server
SQL Server Security
• Instance-level
– Defines who can login to the SQL Server instance
and what permissions they have instance-wide
– sa has instance-wide administrator privileges
– Anyone who can login to the SQL Server is called a
“login”
SQL Server Security
• Database-level
– Defines which logins are able to use this database
and what permissions each has in that database
– By default, database permissions are granular
• Permissions in “AdventureWorks” do not mean a user
has those same permissions in another database
SQL Server Security
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server Security
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server Logins
• Example scenario:
– The Windows Group “SQLDevs” is granted access
– Chad is a member of SQLDevs
– Chad’s latest code check-in caused major data
problems
– What are our options to prevent Chad from
logging in?
SQL Server Logins
• Solution #2:
1. Add Chad’s Windows User account as a login
2. Deny Chad’s Windows User login access
3. Now all other SQLDevs except Chad can login
• PROs
– Does not affect Chad’s other Windows permissions
outside of SQL Server
– SQL Server DBA can implement regardless of Active
Directory access
• CONs
– Requires an extra step
SQL Server Logins
• Let’s demo!
SQL Server 2008 Security
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server Logins
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server Logins
• If you “Disable”:
ALTER LOGIN [login] DISABLE
Status
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Accounts Added by SQL Server
• sa
– Full permissions
– Can be disabled
– Only available in Mixed mode
– Recommendation: DON’T USE IT
• Create Windows authentication logins for your
sysadmins instead
Certificate-based accounts
added
• SQLServerMSSQLUser group:
– Any user in this group can login to SQL Server as a
sysadmin
– Also has the full privileges of the SQL Server
service account
– No need to directly edit this group; SQL Server will
do the right thing when you change service
accounts through the SQL Server Configuration
Manager
Windows-based accounts added
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security: Users
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Database-Level Security
• Let’s demo!
SQL Server 2008 Security: Schemas
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Roles and Schemas
• Organization:
• HumanResources schema in AdventureWorks
contains all objects containing information about
the Human Resources department
Schemas and name resolution
• Let’s demo!
SQL Server 2008 Security: Roles
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Roles
User Permission
Micah, Thomas Full control
Sam, Nica Developers
All others Read all tables; modify
dbo.Customer
User Permission
Micah, Thomas Full control
Sam, Nica Developers
All others Read all tables; modify
dbo.Customer
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security: Roles
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Roles
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security:
Permissions
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
The GDR
Permission Description
Administer bulk operations Required to perform bulk operations
Alter any login Change anyone’s password, et al
Control server Sysadmin privileges
Create any database Allows non-sysadmins to create databases
Shutdown Uhhhhhhhhh
View any database Can see metadata about every database; PUBLIC has this
permission by default
View any definition Discussed on next slide
View server state Discussed on next slide
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security:
Database Permissions
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Securables and Principals
Permission Description
Alter any application role Change passwords
Alter any role Create/alter/drop app roles, modify privileges
Alter any schema Create/alter/drop schemas, modify perms, change
object ownership
Alter any user Create/alter/drop users, rename user; change default
schema
Backup database Can perform FULL and DIFFERENTIAL backups
Backup log Can perform LOG backups
Control Same permission as dbo
View database state Required to view dynamic management views (DMVs)
related to database state
Developer-related permissions
Permission Description
Create assembly Load new assemblies into database
Create function Can create functions in any schema unless specifically
denied
Create procedure Can create stored procedures in any schema unless
specifically denied
Create table Can create tables in any schema unless specifically
denied
Create view Can create views in any schema unless specifically
denied
Select Same as placing in db_datareader
Insert, Update, Delete Same as db_datawriter
Database scoped permissions
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Securables and Principals
• Schema-scoped permissions
– Apply to objects in the schema only
– Can assign permissions to:
• Tables, views, procedures, functions and much more
INSERT, UPDATE, User may perform these operations (specified individually) on all
DELETE, SELECT objects in schema
VIEW DEFINITION User may view definition (i.e. metadata) on all objects in schema
Roles and Schemas
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Impersonation and EXECUTE AS
{ EXEC | EXECUTE ] AS
<context_specification>
[;]
<context_specification>::=
{ LOGIN | USER } = 'name'
[ WITH { NO REVERT | COOKIE INTO
@varbinary_variable } ]
| CALLER
• Server-level impersonation:
– Once you switch, you are no longer you; you are
the login you are now impersonating
– Use REVERT to return to your original context
– Can impersonate while impersonating!
• Database-level impersonation:
– Once you switch, you are no longer you; you are
the user you are now impersonating
– Use REVERT to return to your original context
– Can also impersonate while impersonating
• One “gotcha”: once triggered, you cannot
access objects from databases that do
not have a guest account
Impersonation and EXECUTE AS
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Ownership
• Database ownership:
– The database owner is a login
– The dbo user is the database owner
– By placing users in the db_owner role, they have
similar permissions
• However, the dbo can DENY privileges to the members
of the db_owner role
Cross database ownership
chaining
• Object ownership:
– You can grant CONTROL on certain objects within
a schema instead of granting permission on the
entire schema
Object Ownership
• Example #1
– Terry owns the “Sales” schema
– Terry leaves the company and we hire Chad to
replace him
– We transfer ownership of the “Sales” schema to
Chad
Object Ownership
• Example #2
– Chrissy owns a table in the “Sales” schema named
“Prospects”
– Chad owns the schema
– We hire Candy to replace Chrissy
– We grant CONTROL on “Sales.Prospects” to Candy
– We remove Chrissy!
In the next videos…
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Object Ownership
• Why is this?
– ___________________
Example #1
• Why is this?
– He is the dbo and has full rights to the database
Example #2
• Ownership chains
• How impersonation can affect
permissions
• How to transfer ownership of databases
and schemas
SQL Server 2008 Security:
Ownership
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Object Ownership
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Object Ownership
• Chrissy:
– Owns Admin schema
– Has CREATE VIEW privilege
– Creates a view, Admin.GetMerchants, based on dbo.Merchant
• EXECUTE AS ‘user_name’
– All access to other tables and modules in this
module is done via the security context of
‘user_name’
– Creator of module must have IMPERSONATE
‘user_name’
Impersonation in Modules
• EXECUTE AS SELF
– All access to other tables and modules in this
module is done via the security context of the
creator of the module
Impersonation in Modules
• EXECUTE AS OWNER
– All access to other tables and modules in this
module is done via the security context of the
current owner of the module
Example #1:
• Chrissy:
– Owns Admin schema
– Has CREATE VIEW privilege
– Creates a view, Admin.GetMerchants, based on dbo.Merchant
– Has IMPERSONATE „Terry‟
ALTER AUTHORIZATION ON
SCHEMA::[Customer] TO [Terry]
To Transfer an Object
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Encryption Overview
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Encryption Overview
• To enable TDE:
– Step 1: Create a master key in the master
database
– Step 2: Create a certificate based on the master
key
– Step 3: Create a database encryption key
– Step 4: Turn it on!
• Let’s look at each step
Encryption
• To enable TDE:
– Step 1: Create a master key in the master
database
– Step 2: Create a certificate based on the master
key
– Step 3: Create a database encryption key
– Step 4: Turn it on!
Encryption
USE master
GO
CREATE MASTER KEY
ENCRYPTION BY PASSWORD = 'password„
-- Encrypted using Triple DES
Encryption
• To enable TDE:
– Step 1: Create a master key in the master
database
– Step 2: Create a certificate based on the master
key
– Step 3: Create a database encryption key
– Step 4: Turn it on!
• Let’s look at each step
Encryption
• To enable TDE:
– Step 1: Create a master key in the master
database
– Step 2: Create a certificate based on the master
key
– Step 3: Create a database encryption key
– Step 4: Turn it on!
Encryption
• To enable TDE:
– Step 1: Create a master key in the master
database
– Step 2: Create a certificate based on the master
key
– Step 3: Create a database encryption key
– Step 4: Turn it on!
Encryption
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Distributed Queries Overview
• Linked Servers:
– Allow you to write easy Transact-SQL statements
against multiple data sources without having to
enter login credentials with each query
– Login credentials are stored with the linked
server’s definition
– Used whenever you need to repeatedly access an
external data source from within SQL Server and
do not want to have to enter credentials each
time
Linked Servers
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
Pass-through queries
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
SQL Server 2008 Security: SIDs and
Users - What You Need to Know
Database-level Security
More….
• Chapter • Database • Encryption
Overview principals overview
• Reducing the • Schemas • Linked
attack • Roles servers
surface area • Assigning • SIDs and
• An Overview Database User
of SQL Server permissions accounts
Security
Model
• Logins and
Permissions
What is a SID?
• No!
– You have not created the BigLogin login on the
new server
• Lesson learned… So you go create the
BigLogin SQL Server authentication login
on the new server
• Will your application be able to connect?
Example
• Maybe!
– It depends on whether or not you have set the
default database for the connection string to be
OurDb
• If you set it, you cannot log in
• If you did not set it (unlikely), then you can log in
Restoring Databases
Overview
Restoring Databases
Overview
Restoring Databases
Overview
Restoring Databases
Overview
• Dispelling myths
– You do not need to take a database offline to back
it up
– Backups will include open transactions
– All backups include the transaction log
– You cannot just backup a table by default
• “All or nothing”
• One exception: if that table is on a separate filegroup
What We’re Going to Cover
Restoring Databases
Overview
Restoring Databases
Overview
Restoring Databases
Overview
• Let me recap:
– Bulk Logged and Full recovery models are identical
provided no bulk operations have occurred since
the last backup
– Bulk Logged recovery model may prevent you
from backing up your log
Bulk Logged Recovery Model
Restoring Databases
Overview
Restoring Databases
Overview
Restoring Databases
Overview
Restoring Databases
Overview
• Basics of restores:
– The final backup you restore will, by default, take
the database through the RECOVERY process and
bring the database ONLINE
• You decide which is the final backup file in your
Transact-SQL code
– Any open transactions in the database will be
rolled back during the RECOVERY process
The Basics of Restoring
Databases
• Example restore:
– FULL backup: from Monday: 0800
– LOG backups: Monday: 0900, 1000, 1100
– DIFF backup: Monday 1200
– LOG backups: Monday: 1300, 1400, 1500
The Basics of Restoring
Databases
73
In this video…
Restoring Databases
Overview
• Factors to consider:
1. Size of database
2. Time it takes for each backup type to complete
3. How much “drag” backups place on the system
4. How much disk space our backups consume
5. Where to put the backups?
6. How much “loss” is acceptable
7. How much downtime is acceptable
Factors to consider
1. Size of database
– Large databases are problematic:
• Backup time can be hours and hours
– Therefore the restore time can be hours and hours
• Backup file sizes are huge
– In SQL Server 2008 Enterprise Edition, backup files can be
compressed (more on this later)
• Since the backups are so massive, they have an impact
on system performance
– Smaller and mid-size databases do not have as
much to worry about
Factors to consider
90
In this video…
Restoring Databases
Overview
Backup Strategy:
• Full backups on Saturdays at 2300
Database: LIFUtility
Recovery model: SIMPLE
Backup Strategy:
• Full backups on Saturdays at 2300
Database: LIFUtility
Recovery model: SIMPLE
Backup Strategy:
• Full backups on Saturdays at 2300
Database: LIFUtility
Recovery model: SIMPLE
Backup Strategy:
• Full backups on Saturdays at 2300
Database: LIFUtility
Recovery model: SIMPLE
Backup Strategy:
• Full backups on Saturdays at 2300
• Differential backup Wednesday at
2300
Database: LIFUtility
Recovery model: SIMPLE
Backup Strategy:
• Full backups on Saturdays at 2300
• Differential backup Wednesday at
2300
Database: LIFUtility
Recovery model: SIMPLE
103
In this video…
Restoring Databases
Overview
Backup Strategy:
• Full backups on Saturdays at 2300
• Differential backups each day at
2300
Database: LIFUtility
Recovery model: FULL
Backup Strategy:
• Full backups on Saturdays at 2300
• Differential backups each day at
2300
Database: LIFUtility
Recovery model: FULL
• Question #1:
– What would happen if we accidently
forgot to take the log backup in Step
1?
• We would lose all changes since the DIFF
Backup Strategy
• Question #2:
– What would happen if the disk(s)
holding the data file crashed during
the backup of the log?
• Remember that we can still backup the
log because changes are written to the
log first, and then to the data file
– This is a primary function of the transaction
log
Backup Strategy
• Question #3:
– What would happen if the disk(s)
holding the transaction log crashed
during the backup of the log?
• We would lose all changes since the DIFF
Be Careful!
118
In this video…
Restoring Databases
Overview
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
• Log backups each hour
Database: LIFWeb
Recovery model: FULL
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
• Log backups each hour
Database: LIFWeb
Recovery model: FULL
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
• Log backups each hour
Database: LIFWeb
Recovery model: FULL
131
In this video…
Restoring Databases
Overview
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
• Hourly log backups
Database: LIFReporting
Recovery model: BULK LOGGED
Backup Strategy:
• Full backups on Saturdays at 2300
• Differentials each day at 2300
• Hourly log backups
Database: LIFReporting
Recovery model: BULK LOGGED
147
In this video…
Restoring Databases
Overview
165
In this video…
Restoring Databases
Overview
• Visualization:
In the next video…
175
In this video…
Restoring Databases
Overview
185
In this video…
Restoring Databases
Overview
198
In this video…
Restoring Databases
Overview
• Basics of restores:
– The final backup you restore will, by default, take
the database through the RECOVERY process and
bring the database ONLINE
• You decide which is the final backup file in your
Transact-SQL code
– Any open transactions in the database will be
rolled back during the RECOVERY process
If you are lucky…
209
In this video…
Restoring Databases
Overview
220
In this video…
Restoring Databases
Overview
• Scenario:
– “Mike” calls you and explains that, sometime
around 11:30AM, a “bad” transaction was issued
by a developer
• Mission critical - must undo this transaction or restore
to point prior to the transaction
• Gotta do it now!
Point-in-time Restores are tricky
227
In this video…
Restoring Databases
Overview
• The Scenario:
– The disk system that held all of your data files
(.mdf) has just crashed and cannot be recovered
– The sysadmins have just completed installing new
drives and building the array
– Now it’s your turn to get that SQL Server back up
and running
Restoring Your Entire Server
setup.exe
/QUIET
/ACTION=REBUILDDATABASE
/INSTANCENAME=instance_name
/SQLSYSADMINACCOUNTS= accounts
[/SAPWD=password]
[/SQLCOLLATION=collation_name]
Restoring Your Entire Server
239
In this video…
Restoring Databases
Overview
• The Scenario:
– The disk system that held all of your data files
(.mdf) has just crashed and cannot be recovered
– The sysadmins have just completed installing new
drives and building the array
– Now it’s your turn to get that SQL Server back up
and running
Restoring Your Entire Server
• Reminders:
– No one can be in your database when you restore
– You are overwriting a database during the restore
• Conceptually think of it in three phases:
1. Delete original database files
2. Create new versions of database files
3. Restore the backup data into the new files
Restoring Your Entire Server
• A word of caution:
– Remember that, if you configure SSMS to open
both Object Explorer and a query window, that is
two connections
Restoring Your Entire Server
1
p. 1
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 2
Chapter Introduction
p. 3
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 4
Moving and Copying Databases
p. 5
Moving and Copying Databases
p. 6
Moving and Copying Databases
p. 7
Chapter 8: Miscellaneous
Administration
8
p. 8
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 9
Orphaned Users
p. 10
Orphaned Users
p. 11
Orphaned Users
p. 12
Orphaned Users
p. 13
Orphaned Users
p. 14
Orphaned Users
p. 15
Orphaned Users
p. 16
In the next video…
p. 17
Chapter 8: Miscellaneous
Administration
18
p. 18
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 19
How to Identify Orphaned Users
p. 20
Orphaned Users
p. 21
Let’s demo!
p. 22
Chapter 8: Miscellaneous
Administration
23
p. 23
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 24
CLR Assemblies
p. 25
CLR Assemblies
p. 26
CLR Assemblies
p. 27
CLR Assemblies
p. 28
CLR Assemblies
p. 29
CLR Assemblies
-- To view setting:
EXEC sp_configure 'clr enabled'
-- run_value = 1: enabled
-- To enable:
EXEC sp_configure 'clr enabled', 1
GO
RECONFIGURE WITH OVERRIDE
p. 30
In the next video…
p. 31
Chapter 8: Miscellaneous
Administration
32
p. 32
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 33
CLR Assemblies
p. 34
SAFE
p. 35
EXTERNAL_ACCESS
p. 36
EXTERNAL_ACCESS
p. 37
How do I know which to use?
p. 38
How do I know which to use?
• As a general guideline:
– Use SAFE for assemblies that need only to do
computations, manipulations, and table access
– Use EXTERNAL_ACCESS for when assemblies need
to go outside SQL Server space
– Use UNSAFE when working with unmanaged code
p. 39
How do I know which to use?
p. 40
How do I know which to use?
USE [LearnItFirst.com]
GO
CREATE ASSEMBLY LIFRegEx
FROM „C:\MyAssembly.DLL‟
WITH PERMISSION_SET = SAFE
p. 41
How do I know which to use?
p. 42
The DBA’s Role
p. 43
The DBA’s Role
p. 44
Chapter 8: Miscellaneous
Administration
45
p. 45
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 46
The Resource Governor
p. 47
Example Usage
p. 48
Example Usage
p. 49
The Resource Governor
p. 50
Resource Pools
p. 51
Workload Groups
p. 52
Workload Groups
p. 53
Classifications
p. 54
The Classifier Function
p. 55
Putting It All Together
p. 56
Words of Wisdom
p. 57
Let’s play!
p. 58
Chapter 8: Miscellaneous
Administration
59
p. 59
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 60
Policy-Based Management
p. 61
Policy-Based Management
p. 62
Policy-Based Management
p. 63
Policy-Based Management
p. 65
Policy-Based Management
p. 66
Policy-Based Management
p. 67
Policy-Based Management
p. 68
In the next video…
p. 69
Chapter 8: Miscellaneous
Administration
70
p. 70
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 71
Policy-Based Management
p. 72
Policy-Based Management
p. 73
Policy-Based Management
p. 74
Policy-Based Management
p. 75
Policy-Based Management
p. 76
Policy-Based Management
p. 77
Policy-Based Management
p. 78
Policy-Based Management
• A (weak?) analogy:
– Conditions are like SELECT statements
• Rows that are returned from running the query are
compliant
p. 79
Policy-Based Management
p. 80
Chapter 8: Miscellaneous
Administration
81
p. 81
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 82
Policy-Based Management
p. 83
Policy-Based Management
p. 84
Policy-Based Management
p. 85
Policy-Based Management
p. 86
Policy-Based Management
p. 87
Policy-Based Management
p. 88
Policy-Based Management
p. 89
Policy-Based Management
p. 90
Policy-Based Management
• Explanation:
– “Stored procedure” is the facet and we must find
all stored procedures whose Name property starts
with usp_
– “Database” is the facet and we must find only that
database whose name is WebMarketing
p. 91
In the next video…
p. 92
Chapter 8: Miscellaneous
Administration
93
p. 93
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 94
Policy-Based Management
p. 95
Policy-Based Management
p. 96
Policy-Based Management
p. 97
Policy-Based Management
p. 98
Policy-Based Management
p. 99
Policy-Based Management
p. 100
In the next video…
p. 101
Chapter 8: Miscellaneous
Administration
102
p. 102
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 103
Evaluations
p. 104
Execution Modes
p. 105
Execution Modes
p. 106
Execution Modes
p. 107
Execution Modes
p. 108
Execution Modes
p. 109
Execution Modes
p. 110
Summary
p. 111
In the next video…
p. 112
Chapter 8: Miscellaneous
Administration
113
p. 113
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 114
Writing Policies and Conditions
p. 115
Writing Policies and Conditions
p. 116
Writing Policies and Conditions
p. 117
Writing Policies and Conditions
p. 118
Writing Policies and Conditions
p. 119
Writing Policies and Conditions
p. 120
In the next video…
p. 121
Chapter 8: Miscellaneous
Administration
122
p. 122
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 123
Writing Policies and Conditions
p. 124
Writing Policies and Conditions
p. 125
Writing Policies and Conditions
p. 126
Writing Policies and Conditions
p. 127
Writing Policies and Conditions
p. 128
Writing Policies and Conditions
p. 129
Writing Policies and Conditions
p. 130
Writing Policies and Conditions
p. 131
Writing Policies and Conditions
p. 132
In the next video…
p. 133
Chapter 8: Miscellaneous
Administration
134
p. 134
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 135
PowerShell!
p. 136
PowerShell!
p. 137
PowerShell!
p. 138
PowerShell!
p. 139
PowerShell!
p. 140
PowerShell!
p. 141
PowerShell!
p. 142
PowerShell!
p. 143
In the next video…
p. 144
Chapter 8: Miscellaneous
Administration
145
p. 145
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 146
Unstructured Data
p. 147
Unstructured Data
• 2010:
– Storage: SQL Server 2008
– Tables to store an insured family: 50
– Type of data stored: row data, xml, images, audio
– Export formats: CSV, text, xml, images, audio
p. 148
Unstructured Data
p. 149
Unstructured Data
p. 150
Unstructured Data
p. 151
Unstructured Data
p. 152
Unstructured Data
p. 153
Unstructured Data
p. 154
Unstructured Data
p. 155
Unstructured Data
p. 156
In the next video…
p. 157
Chapter 8: Miscellaneous
Administration
158
p. 158
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 159
FILESTREAM
p. 160
FILESTREAM
p. 161
FILESTREAM
• FILESTREAM requires
both SQL Server DBA
and the Windows
admin
– The SQL Server Service
must be configured for
FILESTREAM access first
using the SQL Server
Configuration Manager
p. 162
FILESTREAM
p. 163
FILESTREAM
p. 164
FILESTREAM
p. 165
FILESTREAM
p. 166
Enable FILESTREAM on a
Database
p. 167
Enable FILESTREAM on a
Database
p. 168
Enable FILESTREAM on a
Database
p. 169
FILESTREAM
p. 170
FILESTREAM
p. 171
FILESTREAM
p. 172
In the next video…
p. 173
Chapter 8: Miscellaneous
Administration
174
p. 174
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 175
FILESTREAM
p. 176
FILESTREAM
USE [LearnItFirst.com]
GO
CREATE TABLE dbo.ClaimImage (
ClaimId INT NOT NULL PRIMARY KEY
, TheImage VARBINARY(MAX) FILESTREAM NOT NULL
, RowId UNIQUEIDENTIFIER NOT NULL
ROWGUIDCOL UNIQUE DEFAULT NEW_ID()
)
-- Tables with FILESTREAM data must have a
-- non-null UNIQUEIDENTIFIER column
p. 177
FILESTREAM
p. 178
FILESTREAM
p. 179
FILESTREAM
p. 180
FILESTREAM Best Practices
p. 181
FILESTREAM
• Final thoughts…
– Transact-SQL’s DELETE statement causes the
physical file to be deleted
• Physical file deletion is not performed until a
CHECKPOINT operation
– Do not attempt to manage files via the file system
• Cannot change names, attributes or delete files
– There are other options…
• Search for “SQL Server 2008 remote BLOB storage”
p. 182
Chapter 8: Miscellaneous
Administration
183
p. 183
What We’re Going to Cover
Management
Overview
• Chapter • Resource
Introduction Governor
• Moving and
Copying Databases
• Policy-Based
• Dealing with
Management
Orphaned Users • Powershell
• CLR and .NET • FILESTREAM
Assemblies • Snapshots
p. 184
Database Snapshots
p. 185
Database Snapshots
p. 186
Database Snapshots
-- At 0800, we execute:
CREATE DATABASE LIFSnapshot_0800
ON(NAME=„LearnItFirst‟
,FILENAME=„D:\LIF_0800.ss‟)
AS SNAPSHOT OF LearnItFirst
-- Logical file name must be
-- same as source. Also note
-- that we do not define a log
p. 187
Database Snapshots
USE LIFSnapshot_0800
GO
-- Returns data up through 0800:
SELECT * FROM dbo.MyTable
GO
-- Changes after 0800 are unseen
p. 188
Database Snapshots
p. 189
Database Snapshots
p. 190
Database Snapshots
• Example restore:
p. 191
Database Snapshots
p. 192
Database Snapshots
p. 193
Database Snapshots
p. 194
Database Snapshots
p. 195
Database Snapshots
• Final thoughts…
– Pros:
• Great way to provide users with a point-in-time view of
database
• Snapshots are quick and easy to create thanks to sparse files
– Cons:
• No way to create using SSMS graphical tools; T-SQL only
• Cannot change user permissions for snapshot vs. source
– A snapshot is a read-only copy of the source
• Added overhead to source database whenever changes occur
– Transaction is not complete until snapshot is up to date
p. 196
Chapter 9: Monitoring and
Performance
1
p. 1
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 2
Chapter Introduction
p. 3
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 4
Tools of Performance Monitoring
p. 5
Tools of Performance Monitoring
p. 6
In the next video…
p. 7
Chapter 9: Monitoring and
Performance
8
p. 8
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 9
SQL Server Profiler
p. 10
SQL Server Profiler
p. 11
SQL Server Profiler
p. 12
SQL Server Profiler
p. 13
SQL Server Profiler
p. 14
SQL Server Profiler
p. 15
SQL Server Profiler
p. 16
SQL Server Profiler
p. 17
In the next video…
p. 18
Chapter 9: Monitoring and
Performance
19
p. 19
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 20
Dynamic Management Views
p. 21
Tools of Performance Monitoring
Reminder…
Perf Data
Profiler DMVs
Mon Coll.
Provides “live”, real-time reporting?
p. 22
Dynamic Management Views
p. 23
Dynamic Management Views
p. 24
Dynamic Management Views
p. 25
Dynamic Management Views
p. 26
DMV and DMF Query
p. 27
DMV and DMF Query Results
p. 28
Database Category
• Database category:
– 16+ DMVs and DMFs
p. 29
In the next video…
p. 30
Chapter 9: Monitoring and
Performance
31
p. 31
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 32
Dynamic Management Views
p. 33
Database Category
• Database category:
– 16+ DMVs and DMFs
p. 34
Database Category
p. 35
Database Category
p. 36
Database Category
p. 37
In the next video…
p. 38
Chapter 9: Monitoring and
Performance
39
p. 39
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 40
Dynamic Management Views
p. 41
Execution/Session Category
• Execution/Session category:
– 20+ DMVs and DMFs
p. 42
Execution/Session Category
p. 43
Execution/Session Category
p. 44
Execution/Session Category
p. 45
Return 50 most-run queries
p. 46
Return 50 most-run queries
p. 47
Execution/Session Category
p. 48
Execution/Session Category
p. 49
In the next video…
p. 50
Chapter 9: Monitoring and
Performance
51
p. 51
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 52
Dynamic Management Views
p. 53
IO Category
• IO category:
– 4+ DMVs and DMFs
p. 54
IO Category
p. 55
IO Category
• sys.dm_io_virtual_file_stats
returns several columns:
Column Description
sample_ms Milliseconds since server was restarted
num_of_reads Physical reads of objects in database file
num_of_bytes_read Large textual-based columns will affect this greatly
io_stall_read_ms Total time a user process waited for IO to this file
num_of_writes, Database write activity
num_of_bytes_written,
io_stall_write_ms
io_stall Total amount of waits reading /writing to this file
p. 56
IO Category
p. 57
IO DMF
p. 58
IO DMF
p. 59
IO DMF
p. 60
OS Category
p. 61
OS Category
p. 62
OS Category
p. 63
OS Category
p. 64
OS Category
p. 65
OS Category
p. 66
In the next video…
p. 67
Chapter 9: Monitoring and
Performance
68
p. 68
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 69
OS Category
p. 70
OS Category
p. 71
OS Category
p. 72
OS Category
p. 73
OS Category
p. 74
OS Category
p. 75
OS Category
p. 76
OS Category
p. 77
OS Category
p. 78
OS Category
p. 79
Scary!
p. 80
OS Category
p. 81
OS Category
p. 82
In the next video…
p. 92
Chapter 9: Monitoring and
Performance
93
p. 93
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 94
Performance Monitor
p. 95
Performance Monitor
p. 96
Performance Monitor
p. 97
Performance Monitor
p. 98
Performance Monitor
p. 99
Performance Monitor
p. 100
Performance Monitor
p. 101
Performance Monitor
p. 102
Performance Monitor
p. 103
In the next video…
p. 104
Chapter 9: Monitoring and
Performance
105
p. 105
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 106
Performance Monitor
p. 107
Performance Monitor
p. 108
Performance Monitor
p. 109
Performance Monitor
p. 110
Disk Usage
p. 111
Disk Usage
p. 112
Disk Usage
Memory Page faults/sec “Some” page faults are normal; look for
consistently high numbers
p. 113
Disk Usage
p. 114
Disk Usage
p. 115
Disk Usage
p. 116
Disk Usage
p. 117
Disk Usage
p. 118
One Caveat
p. 119
A Final Caveat
p. 120
In the next video…
p. 121
Chapter 9: Monitoring and
Performance
122
p. 122
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 123
Data Collector
p. 124
Data Collector
p. 125
Data Collector
p. 126
Data Collector
p. 127
Data Collector
p. 128
Data Collector
p. 129
Data Collector
p. 130
Data Collector
• A disclaimer:
– Please test, test, test this prior to deploying in a
production environment
– This is version 1.0 software
– Easy to “over collect”
• 30GB of data collection in three days!
p. 131
Data Collector
p. 132
Data Collector
p. 133
In the next video…
p. 134
Chapter 9: Monitoring and
Performance
135
p. 135
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 136
Data Collector
p. 137
Data Collector
p. 138
Data Collector
p. 139
Data Collector
p. 140
Data Collector
p. 141
Data Collector
p. 142
Data Collector
p. 143
Data Collector
p. 144
Data Collector
p. 145
In the next video…
p. 146
Chapter 9: Monitoring and
Performance
147
p. 147
What We’re Going to Cover
Overview
Monitoring
• Chapter • Understanding
Introduction and Using the
• Tools for DMVs
Monitoring • PerfMon
• SQL Server • Data Collector
Profiler
p. 148
Data Collector
p. 149
Data Collector
p. 150
Data Collector
p. 151
Data Collector
p. 152
Data Collector
p. 153
Data Collector
p. 154
Data Collector
p. 155
In the next video…
p. 156
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
p. 2
What We’re Going to Cover
p. 3
High Availability
p. 4
High Availability
p. 5
High Availability
p. 6
High Availability
p. 7
High Availability
p. 8
High Availability
p. 9
High Availability
p. 10
In the next video
p. 11
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
p. 2
Log Shipping Best Practices
p. 3
Log Shipping Best Practices
p. 4
Log Shipping Best Practices
p. 5
Log Shipping Best Practices
p. 6
Log Shipping Best Practices
p. 7
Log Shipping Best Practices
p. 8
Log Shipping Best Practices
p. 9
Log Shipping Best Practices
p. 10
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
p. 2
Database Mirroring Best
Practices
p. 3
Database Mirroring Best
Practices
p. 4
Database Mirroring Best
Practices
p. 5
Database Mirroring Best
Practices
p. 6
Database Mirroring Best
Practices
p. 7
Database Mirroring Best
Practices
p. 8
Database Mirroring Best
Practices
p. 9
Database Mirroring Best
Practices
p. 10
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
Overview
p. 2
SQL Clustering Best Practices
p. 3
SQL Clustering Best Practices
p. 4
SQL Clustering Best Practices
p. 5
SQL Clustering Best Practices
p. 6
SQL Clustering Best Practices
p. 7
SQL Clustering Best Practices
p. 8
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
p. 2
SQL Server Replication
p. 3
SQL Server Replication
• Basic terms:
– Publisher: the source database
– Publication: the tables, views, and stored
procedures that the publisher is publishing
– Subscriber: the database receiving the
changes
– Subscription: how the subscriber receives
the data
– Distributor: the server responsible for
delivering the publication to the subscriber
p. 4
SQL Server Replication
p. 5
SQL Server Replication
p. 6
SQL Server Replication
p. 7
Snapshot Replication
• Snapshot replication:
– Publisher generates a snapshot - a point-in-time
copy of the publication
– Distribution then replaces copy of subscribers’
data with the snapshot
• Typically one-way replication (data entered only at
publisher)
– Analogy: Newspaper industry
p. 8
Snapshot Replication
p. 9
In the next video…
p. 10
Chapter 10: High Availability
1
p. 1
What We’re Going to Cover
Overview
p. 2
Merge Replication
• Merge replication:
– Basic premise: Anyone can change the data
– Transactions are replicated
• Unlike Snapshot replication which replicates entire
snapshot
– Changes are synchronized between all servers
p. 3
Merge Replication
• Merge replication:
– Setup flow:
1. Create the publication and generate the snapshot
2. Distribute snapshot to subscribers
– At this point, Publisher and Subscribers have same data
3. Someone changes the data (could be Pub or Sub)
4. Merge Agent handles merging the data so that, in the
end, everyone has the same data
p. 4
Merge Replication
p. 5
Merge Replication
p. 6
Merge Replication
p. 7
Transactional Replication
• Transactional replication:
– Transactions are replicated between servers
– Transactional can:
• Be one-way: only the Publisher can replicate changes
• By multi-way: changes can occur at any site
– Transactional may or may not have conflict
detection
• Depends on topology
• Rule of thumb: “Last in wins” unless you configure
differently
p. 8
Transactional Replication
p. 9
P2P Transactional Replication
p. 10
P2P Transactional Replication
p. 11
P2P Transactional Replication
p. 12
Let’s demo!
p. 13