SQL Server 2008 New Features

download SQL Server 2008 New Features

of 33

Transcript of SQL Server 2008 New Features

  • 8/4/2019 SQL Server 2008 New Features

    1/33

    SQL SERVER 2008 NEW FEATURESJeff R. Johnson| Lead SQL Architect

    [email protected]| 973-401-0660

  • 8/4/2019 SQL Server 2008 New Features

    2/33

    AGENDA

    SECURITYAND DATA AUDITING 4

    AVAILABILITYAND RELIABILITY 8

    PERFORMANCE 10

    MANAGEMENT 13

    NEW DATA TYPES 14

    DEVELOPMENT ENHANCEMENTS 15

    SERVICEBROKER 20

    DATA STORAGE 21

  • 8/4/2019 SQL Server 2008 New Features

    3/33

    AGENDA

    DATA WAREHOUSING/ETL 27

    REPORTING 31

    DEPRECATION 32

    Q & A 33

  • 8/4/2019 SQL Server 2008 New Features

    4/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    SECURITYANDDATAAUDIT

    ING

    TRANSPARENT DATA ENCRYPTION

    Encryption of data on the disk while it remains transparent to the application

    requesting the data.

    Steps

    1. Create a Master Key

    2. Create or obtain a certificate protected by the master key

    3. Create a database encryption key and protect it by the certificate

    4. Set the database to use encryption

  • 8/4/2019 SQL Server 2008 New Features

    5/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    SECURITYANDDATAAUDIT

    ING

    TRANSPARENT DATA ENCRYPTION

    Use master

    go

    Create Master Key

    Encryption by Password = mssqlR0cks

    Go

    Create Certificate TDECert

    With Subject = TDE Certificate

    Go

    Create Database TDESample

    Go

    Use TDESample

    Go

    Create Database Encryption Key

    With Algorithm = AES_256

    Encryption by Server Certificate TDECert

    Go

    Alter database TDESampleSet Encryption On

    Go

  • 8/4/2019 SQL Server 2008 New Features

    6/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    SECURITYANDDATAAUDIT

    ING

    EXTENSIBLE KEY MANAGEMENT

    Features Support for Hardware Security Modules (HSM)

    HSM devices store encryption keys in hardware or software modules

    More secure because encryption keys do not reside with the data

    Higher performance for hardware-based encryption/decryption

    Additional authorization check

    Secure encryption key disposal

    Easier retention and retrieval

    Turn on EKM

    Sp_configure show advanced,1

    Go

    Reconfigure

    GoSp_configure EKM provider enabled,1

    Go

    Reconfigure

    go

  • 8/4/2019 SQL Server 2008 New Features

    7/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    SECURITYANDDATAAUDIT

    ING

    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

  • 8/4/2019 SQL Server 2008 New Features

    8/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    AVAILABILITYANDRELIABILITY

    HOT SWAP CPUS

    Adds the ability to add CPUs on the fly while the machine is up and running

    Automatically recognizes additional CPU and starts using it

  • 8/4/2019 SQL Server 2008 New Features

    9/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    AVAILABILITYANDRELIABILITY

    DATABASE MIRRORING

    Compressed log steam to minimize network bandwidth

    Automatic page repair for both principal and mirror

    New DMVs (Dynamic Management Views)

    Additional mirroring performance counters

  • 8/4/2019 SQL Server 2008 New Features

    10/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    PERFORMA

    NCE

    BACKUP COMPRESSION

    Setup Server Wide

    Exec sp_configure backup compression default,1

    Reconfigure with override

    Database Backup Syntax

    BACKUP DATABASE AdventureWorks

    To Disk = c:\SQLData\AdventureWorks_Compressed.bak

    With COMPRESSION, INIT

  • 8/4/2019 SQL Server 2008 New Features

    11/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    PERFORMA

    NCE

    PERFORMANCE DATA COLLECTION

    New tool in Management Studio

    Collects data about SQL Server 2008 in collection sets

    Stores data collected in a database

    Allows you to define what are in those sets

    Counters can be from DMVs, SQL Traces, Application Data

    Extensible

    Comes with 3 collection sets

    1. Disk Usage

    2. Query Statistics

    3. Server Activity

  • 8/4/2019 SQL Server 2008 New Features

    12/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    PERFORMA

    NCE

    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)

  • 8/4/2019 SQL Server 2008 New Features

    13/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    MANAGEM

    ENT

    POLICY-BASED MANAGEMENT

    Policy management is done inside SQL Server Manager StudioCreate 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 items1. Target database, table, index, etc

    2. Facet predefined set of properties that can be managed

    3. Condition expression on a facet that evaluates to true or false

    4. Policy a condition to be checked and/or enforced

  • 8/4/2019 SQL Server 2008 New Features

    14/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    NEWDATATYPES

    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

  • 8/4/2019 SQL Server 2008 New Features

    15/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEVELOPMENTENHANCEM

    ENTS

    QUERIES

    LINQ was introduced with Visual Studio 2008SQL 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.

    DEVELOPM

    ENTENHANCEM

    ENTS

  • 8/4/2019 SQL Server 2008 New Features

    16/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEVELOPM

    ENTENHANCEMENTS

    SQL SERVER CHANGE TRACKING

    Change Data Capture

    Provides historical information for a user table by capturing both the fact that DML changes

    were made and the actual data what was changed.. Changes are captured by using anasynchronous process that reads the transaction log and has a low impact on the system.

    Enabling

    Exec sys.sp_cdc_enable_db_change_data_capture

    Go

    Exec sys.sp_cdc_enable_table_change_data_capture @source_schema = dbo, @source_name =

    TestTable, @Role_Name = null

    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 endcdc.dbo_[TableName]_ct. The actual changed data

    Change Tracking

    Captures the fact that rows where changed but doesnt capture what was changed.

  • 8/4/2019 SQL Server 2008 New Features

    17/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEVELOPM

    ENTENHANCEMENTS

    TABLE VALUE PARAMETERS

    Ability to declare table types and pass as variables

    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

  • 8/4/2019 SQL Server 2008 New Features

    18/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEVELOPM

    ENTENHANCEMENTS

    LARGE UDTS

    UDT User Defined DatatypeIntroduced in SQL 2005 had 8k limit

    SQL 2008 has varbinary(max) limit ~ 2GB

  • 8/4/2019 SQL Server 2008 New Features

    19/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEVELOPM

    ENTENHANCEMENTS

    XML ENHANCEMENTS

    Datetime, date, and time validation including timezone

    information in schema collectionsBetter support for union and list types

    Support for LAX validation (anytype and anyattribute

    validation)

    Modify method now allows DMLAdds let clause in XQuery

  • 8/4/2019 SQL Server 2008 New Features

    20/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    SERVICEBROKER

    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 } ]

    )

    ]

  • 8/4/2019 SQL Server 2008 New Features

    21/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    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)

  • 8/4/2019 SQL Server 2008 New Features

    22/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    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 afterpage header. Reference number refers to prefix.

    Dictionary Compression Searches for duplicate values in a page and storesthem in the compression information header. Prefix is only one column anddictionary 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)

  • 8/4/2019 SQL Server 2008 New Features

    23/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    FILE STREAM

    Ability to store objects in the file system but still be managed by SQLServer

    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

    SampleExec sp_filestream_configure @Enable_level =3, @share_name = FilesteamShare

    GoAlter 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

  • 8/4/2019 SQL Server 2008 New Features

    24/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    INTEGRATED FULL TEXT SEARCH

    Full Text Search is now integrated into SQL Server 2008

    Improvement include:

    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

  • 8/4/2019 SQL Server 2008 New Features

    25/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    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)

  • 8/4/2019 SQL Server 2008 New Features

    26/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATASTORAGE

    NEW INDEX TYPES

    Filtered Index

    Optimized Non-clustered index

    Uses filter to index a portion of a table

    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

  • 8/4/2019 SQL Server 2008 New Features

    27/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATAWAR

    EHOUSING/ETL

    PARTITION TABLE PARALLELISM

    Removes the 1 CPU limit on queries against partitioned tables

    New syntax to switch partitioned tables

    SampleAlter table PartitionTable Switch Partition 2 to NonPartitionTable

  • 8/4/2019 SQL Server 2008 New Features

    28/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATAWAR

    EHOUSING/ETL

    ANALYSIS SERVICES

    Star Join Supportoptimized 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

  • 8/4/2019 SQL Server 2008 New Features

    29/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATAWAR

    EHOUSING/ETL

    INTEGRATION SERVICES (SSIS)

    Persistent LookupsImproved Thread Scheduling

  • 8/4/2019 SQL Server 2008 New Features

    30/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DATAWAR

    EHOUSING/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

  • 8/4/2019 SQL Server 2008 New Features

    31/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    REPORTING

    REPORTING SERVICES ENHANCEMENTS

    IIS no longer requiredMore charting choices

    Export report to rich text format

    Export report to word format

    Built in forms authentication

  • 8/4/2019 SQL Server 2008 New Features

    32/33

    Capax | Global | NY Metro HQ | 10 Sylvan Way | Parsippany, NJ 07045 | 973-401-0660

    DEPRICATIO

    N

    DEPRICATION

    SQL Server 6.0, 6.5 and 7.0 compatibilty modes removed

    NOLOG and TRUNCATEONLY on backup commandRemote Server support

    Security

    Sp_addalias

    sp_dropalias

    Sp_addgroup

    Sp_changegroup

    Sp_dropgroup

    Sp_helpgroup

    SetUser

  • 8/4/2019 SQL Server 2008 New Features

    33/33

    Q&A

    QUESTIONAND ANSWERS

    Question and Answers