Professional Documents
Culture Documents
Administration
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