Escolar Documentos
Profissional Documentos
Cultura Documentos
AGENDA
4 8
PERFORMANCE
MANAGEMENT
10
13
14
15 20 21
AGENDA
27 31
DEPRECATION Q&A
32 33
Turn on EKM
Sp_configure show advanced,1 Go Reconfigure Go Sp_configure EKM provider enabled,1 Go Reconfigure go
AUDITING
Server Audits Audit events that happen at the server level (Login, Logout, Groups, etc.)
CREATE SERVER AUDIT [LoginAudit] TO APPLICATION_LOG WITH ( QUEUE_DELAY = 1000 ,ON_FAILURE = CONTINUE ) GO CREATE SERVER AUDIT SPECIFICATION [TestServerAudit] FOR SERVER AUDIT [LoginAudit] ADD (SUCCESSFUL_LOGIN_GROUP) WITH (STATE = ON) GO
Database Audits Audit events that happen at the database level (Schema, Ownership, Data, etc.)
CREATE DATABASE AUDIT SPECIFICATION [SchemaAudit] FOR SERVER AUDIT [SchemaAudit] ADD (SCHEMA_OBJECT_CHANGE_GROUP) WITH (STATE = On) GO
DATABASE MIRRORING
Compressed log steam to minimize network bandwidth Automatic page repair for both principal and mirror
PERFORMANCE
BACKUP COMPRESSION
Setup Server Wide
PERFORMANCE
PERFORMANCE
RESOURCE GOVERNOR
Limit the amount of CPU by percent Limit the amount of Memory by percent Applied by a workload group Workload group is defined by a custom classifier function
CREATE RESOURCE POOL [TestResourcePool] WITH(min_cpu_percent=0, max_cpu_percent=5, min_memory_percent=0, max_memory_percent=5) GO CREATE WORKLOAD GROUP [TestWorkloadGroup] WITH (importance=Medium) USING [TestResourcePool] GO Create Function TestResourcePoolMember() Returns Sysname with schemabinding as Begin Declare @name as SysName = 'default' if (suser_name() <> 'sa') Set @name = 'TestWorkloadGroup' Return @name End Go Alter Resource Governor with (Classifier_Function = dbo.TestResourcePoolMember)
MANAGEMENT
POLICY-BASED MANAGEMENT
Policy management is done inside SQL Server Manager Studio Create policies Export Policies to XML files Evaluate group of Servers for an exported policy Install policies on each server or group of servers Easier to administer and support multiple servers Policy consists of 4 items
1. 2. 3. 4. Target database, table, index, etc Facet predefined set of properties that can be managed Condition expression on a facet that evaluates to true or false Policy a condition to be checked and/or enforced
DATA TYPES
Date Time2(7) - Millisecond up to 7 digits DateTimeOffset(7) DateTime2 with Offset for TimeZone Geometry Geography HierarchyID Time(7) Time only up to 7 digit milliseconds Date Date Only
DEVELOPMENT ENHANCEMENTS
QUERIES
LINQ was introduced with Visual Studio 2008 SQL 2008 ships with a LINQ to SQL Provider which allows LINQ commands directly against SQL Server ADO.NET Entity framework allows developers to create database queries using entities.
DEVELOPMENT ENHANCEMENTS
DEVELOPMENT ENHANCEMENTS
Results New tables cdc.captured_columns Information about the captured columns being tracked. cdc.changed_tables Tables being tracked. cdc.ddl_history Changes to the tracked table. cdc.index_columns Tracked index columns. cdc.lsn_time_mapping Tracks when a transaction starts and end cdc.dbo_[TableName]_ct. The actual changed data
Change Tracking Captures the fact that rows where changed but doesnt capture what was changed.
DEVELOPMENT ENHANCEMENTS
Sample
Create type KeyList as TABLE (RowKey int) GO Declare spGetRows (@KeyList KeyList) Begin Select * From Employees = K.RowKey End Go Declare @Rows KeyList Insert into @Rows Values(1) Insert into @Rows Values(2) Exec spGetRows (@Rows) GO
DEVELOPMENT ENHANCEMENTS
LARGE UDTS
UDT User Defined Datatype Introduced in SQL 2005 had 8k limit SQL 2008 has varbinary(max) limit ~ 2GB
DEVELOPMENT ENHANCEMENTS
XML ENHANCEMENTS
Datetime, date, and time validation including timezone information in schema collections Better support for union and list types Support for LAX validation (anytype and anyattribute validation) Modify method now allows DML Adds let clause in XQuery
SERVICE BROKER
CONVERSATION PRIORITY
Now assign a priority to Service Broker conversations
CREATE BROKER PRIORITY ConversationPriorityName FOR CONVERSATION [ SET ( [ CONTRACT_NAME = {ContractName | ANY } ] [ [ , ] LOCAL_SERVICE_NAME = {LocalServiceName | ANY } ] [ [ , ] REMOTE_SERVICE_NAME = {'RemoteServiceName' | ANY } ] [ [ , ] PRIORITY_LEVEL = {PriorityValue | DEFAULT } ] ) ]
DATA STORAGE
DATA COMPRESSION
Row Compression
Minimizes the metadata (Column Info, Length, Offsets, etc) associated with each record Numeric data types and fixed length strings are stored in variable-length storage format like varchar.
Sample
Create Table MyTable ( Id int identity Primary Key, Name char(100), Email char(100)) With (Data_Compression = Row)
Alter table MyTable Rebuilt With (Data_Compression = Row, MaxDop = 2)
DATA STORAGE
DATA COMPRESSION
Page Compression
Uses Row Compression Prefix Compression For every column in a page prefixes are identified. Prefixes are saved in compression information headers which reside after page header. Reference number refers to prefix. Dictionary Compression Searches for duplicate values in a page and stores them in the compression information header. Prefix is only one column and dictionary is complete page.
Sample
Create Table MyTable ( Id int identity Primary Key, Name char(100), Email char(100)) With (Data_Compression = Page) Alter table MyTable Rebuilt With (Data_Compression = Page, MaxDop = 2)
DATA STORAGE
FILE STREAM
Ability to store objects in the file system but still be managed by SQL Server
Store and retrieve BLOBs together with relational data in a single data store. Included in backup and restore operations Inserting, updating, deleting BLOBs and relational data occur in same database transaction 2GB limit of varchar(max) doesnt apply SQL Server buffer pool (memory) is not used BLOB access can be performed from .Net code NTFS file system can save and retrieve data faster than SQL Server
Steps
Configure SQL Server to use Filestream and appropriate level (T-SQL, local system, remote) Create filegroup to database that contains Filestream Add file to database filegroup that contains the Filesteam Add column with Filestream specified in definition
Sample
Exec sp_filestream_configure @Enable_level =3, @share_name = FilesteamShare Go Alter database MyDB Add Filegroup MyFileStreamFG Contains Filestream Go Alter database MyDB add File (name = MyDB_filestream, Filename=c:\db\fs) to filegroup MyFileStreamFG GO Create table TestTable(ID int identity not null, LargeObject VARBINARY(MAX) FILESTEAM NULL) GO
DATA STORAGE
Performance Indexing and Query Stop Lists stored in the database Thesaurus Improvements DMVs Dm_fts_index_keywords Dm_fts_index_keywords_by_document Dm_fts_parser
DATA STORAGE
SPARSE COLUMNS
Sparse columns reduce the amount of storage for null values at the sacrifice of more overhead to retrieve non-null values. Best practice is to use when column contains 20 40 percent null values. Sample
Create Table SparseSample ( KeyValue int idenity not null, Name varchar(100) not null, Address1 varchar(100) not null, Address2 varchar(100) sparse not null, City varchar(50) not null, State char(2) not null, PostalCode varchar(10) not null)
DATA STORAGE
Create NonClustered Index MyIndex On TableName.ColumnName(Col1, Col2) Where Col2 is not null
Spatial Index
Used to index geography and geometry value types Index is created on a column
XML Index
Primary XML Index Creates clustered index on XML Column Secondary XML Index Creates index on Path, Value or Property
DATA WAREHOUSING/ETL
Removes the 1 CPU limit on queries against partitioned tables New syntax to switch partitioned tables Sample
Alter table PartitionTable Switch Partition 2 to NonPartitionTable
DATA WAREHOUSING/ETL
ANALYSIS SERVICES
Star Join Support optimized for better star join query response Better scalability- Can share read-only DBs between several servers New tools for cube design Improved cube backup Can support large databases Excel data-mining add-ins Grouping by sets
DATA WAREHOUSING/ETL
DATA WAREHOUSING/ETL
MERGE STATEMENT
Merge statement works as an insert, update, delete statement all at once Works on two sources of data, the source and the target
Merge Main.dbo.TestTable as Target Using (Select Col1, col2 from stage.dbo.TestTable) as Source On Target.TableKey = Source.TableKey When Matched [and condition] Then Update Set Col1 = Source.Col1, Col2 = Source.Col2 When Matched [and condition] Then Delete When Not Matched Then Insert (Col1, Col2) values (Col1, Col2) Output $action, Inserted.TableKey, Deleted.TableKey
REPORTING
DEPRICATION
DEPRICATION
SQL Server 6.0, 6.5 and 7.0 compatibilty modes removed NOLOG and TRUNCATEONLY on backup command Remote Server support Security Sp_addalias sp_dropalias Sp_addgroup Sp_changegroup Sp_dropgroup Sp_helpgroup SetUser
Q&A