Features in SQL2008(C612114)

download Features in SQL2008(C612114)

of 35

Transcript of Features in SQL2008(C612114)

  • 8/3/2019 Features in SQL2008(C612114)

    1/35

    Hari KishorHari Kishor

  • 8/3/2019 Features in SQL2008(C612114)

    2/35

    Agenda SQL Server 2008 New Features & Enhancements

    Database Engine

  • 8/3/2019 Features in SQL2008(C612114)

    3/35

    SQL Server 2008 Objective

    A ny kind of YOUR DATA A ccess from ANY PLACEat ANY TIME

    Y our Data - structured, semi-structured and unstructured images, musicA ny Place - data center, desktops and mobile devicesA ny Time - control over your data no matter where it is stored

  • 8/3/2019 Features in SQL2008(C612114)

    4/35

    Wha t s New in SQL Server 2008

    SQL Server 2008 Qualities: Trusted Enables organizations to run their most

    critical applications with very high levels of security,reliability, and scalability.

    Productive Enables organizations to reduce thetime and cost required to develop and manage theirdata infrastructure.

    Intelligent Provides a comprehensive platform thatdelivers insights and information where your users want it.

  • 8/3/2019 Features in SQL2008(C612114)

    5/35

    Wha t s New in SQL Server 2008 Trusted

    y Protect Y our Informationy Transparent Data Encryptiony External Key Managementy Enhanced A uditing

    y Ensure Business Continuity y Enhanced Database Mirroringy Hot A dd CPU

    y Optimized and Predictable System Performancey Performance data collectiony

    Extended Eventsy Backup compressiony Data compressiony Resource Governory Plan Freezing

  • 8/3/2019 Features in SQL2008(C612114)

    6/35

    Wha t s New in SQL Server 2008 Productive

    y Policy-based Managementy Compliance with policies for system configurationy Monitors and prevents changes to the system by authoring policies against the

    configurationy Reduces total cost of ownership by simplifying administration tasksy Detects compliance issues in SQL Server Management Studio

    y A ccelerated Developmenty A DO.NET Entity Frameworky

    Language Integrated Query (LINQ)y CLR integration and A DO.NET object servicesy Transact-SQL Improvements

  • 8/3/2019 Features in SQL2008(C612114)

    7/35

    Wha t s New in SQL Server 2008 Productive

    y Streamlined Installationy separate the installation of the bits on the computer from the configuration of the

    SQL Server software

    y Beyond Relational Datay HIER A RCH Y IDy FILESTRE A M Datay Integrated Full-Text Searchy Sparse columnsy

    Large user-defined typesy Geographical Information (GEOGR A PH Y , GEOMETR Y Data types)

  • 8/3/2019 Features in SQL2008(C612114)

    8/35

    Wha t s New in SQL Server 2008 Intelligent

    y Integrate A ny Datay Data compressiony Backup compressiony Partitioned table parallelismy Star join query optimizationsy Resource Governory GROUPING SETSy Change data capturey MERGE SQL statement

  • 8/3/2019 Features in SQL2008(C612114)

    9/35

    M a nag ement Studio En ha ncements Database Engine Query Editor IntelliSense

    y Transact-SQLy Displays Objects/Parametersy SELECT Statement (Ex: SELECT TOP * FROM dbo.Test)y DECL A RE ( ExDECL A RE @Table T A BLE (I))y SET (Ex: SET @Table = 10)y EXECUTE (Parameters)y CRE A TE T A BLE, CRE A TE PROCEDURE

    y Conditions That Affect IntelliSenseIntelliSense options might not work as you expect in following cases:y There is a code error above the cursory The insertion point is inside a code comment/ string literaly The automatic options are turned off

    To turn off IntelliSense optionsTools Options Expand Text Editor Expand A ll Languages/Transact-SQL/XML Click General Clear the check boxes for theStatement Completion options that you do not want

    Object Explorery Customize the columns that are displayed by the Object Explorer Details windowy The properties of a selected item appear at the bottom of the Object Explorer Details window

  • 8/3/2019 Features in SQL2008(C612114)

    10/35

    M a nag ement Studio En ha ncements Policy-Based Management Enhancements (Declarative Management Framework)

    y Provides more than 40 policies to help you monitor SQL Servery H elps to Manage instance of SQL Servery Enforcing Naming Convention

    Execution modes

    There are four possible execution modes, three of which can be automated:y On Demand . This mode evaluates the policy when directly specified by the user.

    y On Change - Prevent . This automated mode uses DDL triggers to prevent policy violations.

    y On Change - Log Only . This automated mode uses event notification to evaluate a policy

    when a relevant change occurs and logs policy violations.y On Schedule . This automated mode uses a SQL Server A gent job to periodically evaluate

    a policy. The mode logs policy violations

  • 8/3/2019 Features in SQL2008(C612114)

    11/35

    M a nag ement Studio En ha ncements Auditing

    SQL Server A udit is a new feature of SQL Server 2008 that lets you create customized audits of Database Engine events. SQL Server A udit uses extended events to record the information for theaudit and provides the tools and processes you must have to enable, store, and view audits on variousserver and database objects

    Database Engine Error List WindowSQL Server Management Studio includes an Error List window that displays the syntax andsemantic errors generated from the IntelliSense code in the Database Engine Query Editor.

    To display the Error List , do one of the following:y On the V iew menu, click Error List .y Enter the keyboard shortcut CTRL+\, CTRL+E.

    A fter you open the Error List , you can customize your view by performing the followingactions:

    y To sort the list, click any column header. To sort again by an additional column, press and hold theSHIFT key, and then click another column header.

    y To select which columns are displayed and which are hidden, select Show Columns from the shortcutmenu.

    y To change the order in which columns are displayed, drag any column header to the left or right

  • 8/3/2019 Features in SQL2008(C612114)

    12/35

    P erform a nce En ha ncements - Compression Sparse Columns and Column Sets

    y Optimized storage format for null valuesy Consider using sparse columns when at least 20 percent to 40 percent of the values in

    a column will be NULL.y Sparse columns require more storage space for non null values than the space

    required for identical data that is not marked SP A RSE.

    y

    A sparse column cannot have a default value.y Computed column cannot be marked as SP A RSE.y Cannot be part of a clustered index or a unique primary key indexy A sparse column cannot be part of a user-defined table typey Using sparse columns reduces the maximum size of a row from 8,060 bytes to 8,018

    bytes

    Data type Non-sparse bytes Sparse bytesInt 4 8

    Datetime 8 12

    Real 4 8

  • 8/3/2019 Features in SQL2008(C612114)

    13/35

    P erform a nce En ha ncements - Compression Tables and Indexes Compression

    y Row/Page level compression for tables, indexes, and indexed views

    y Compression can allow more rows to be stored on a page, but does not change themaximum row size of a table or index.

    y

    A table cannot be enabled for compression when the maximum row size plus thecompression overhead exceeds the maximum row size of 8060 bytes

    y Enabling compression only changes the physical storage format of the data that isassociated with a data type but not its syntax or semantics.

    y A pplication changes are not required when one or more tables are enabled forcompression

    y NULL and 0 values across all data types are optimized and take no bytes.

    y It stores fixed character strings by using variable-length format by not storing theblank characters

  • 8/3/2019 Features in SQL2008(C612114)

    14/35

    P erform a nce En ha ncements - Compression Tables and Indexes Compression

    y It reduces the metadata overhead that is associated with the record. Thismetadata is information about columns, their lengths and offsets. In somecases, the metadata overhead might be larger than the old storage format.(Ex: Bit - The metadata overhead brings this to 4 bits)

    y It uses variable-length storage format for numeric types (for exampleinteger , decimal , and float ) and the types that are based on numeric (forexample datetime and money )

    y To determine the compression state of partitions in a partitioned table,query the data_compression column of the sys.partitions catalog view

    y Because of their size, large-value data types are sometimes stored separately from the normal row data on special purpose pages. Data compression isnot available for the data that is stored separately.

  • 8/3/2019 Features in SQL2008(C612114)

    15/35

    P erform a nce En ha ncements - Compression

    Data compression can be configured for the following database objects:y A whole table that is stored as a heap.y A whole table that is stored as a clustered index.y A whole nonclustered index.y A whole indexed view.y For partitioned tables and indexes, the compression option can be configured

    for each partition, and the various partitions of an object do not have to havethe same compression setting.

    y The compression setting of a table is not automatically applied to itsnonclustered indexes. Each index must be set individually

    y

    Not an alternative to fragmented data

  • 8/3/2019 Features in SQL2008(C612114)

    16/35

    P erform a nce En ha ncements - Compression Compression Estimation

    y sp_estimate_data_compression_savings

    y Returns the current size of tables and estimates the table size for the requestedcompression state. Compression can be evaluated for whole tables or parts of tables.This includes heaps, clustered indexes, nonclustered indexes, indexed views, andtable and index partitions.

    y To estimate the size of the object if it were to use the requested compression setting,this stored procedure samples the source object and loads this data into anequivalent table and index created in tempdb . The table or index create in tempdbis then compressed to the requested setting and the estimated compression savingsis computed.

    y EXEC sp_estimate_data_compression_savings 'Production', 'WorkOrderRouting',NULL, NULL, 'ROW' ;

  • 8/3/2019 Features in SQL2008(C612114)

    17/35

    P erform a nce En ha ncements - Compression Page Compression

    y Page compression is similar for tables, table partitions, indexes, andindex partitions

    y Non leaf-level pages of indexes are compressed by using only rowcompression

    y Compressing the leaf level of tables and indexes with pagecompression consists of three operations in the following order:y Row compressiony Prefix compressiony Dictionary compression

  • 8/3/2019 Features in SQL2008(C612114)

    18/35

    P erform a nce En ha ncements - Compression Prefix compression

    For each page that is being compressed, prefix compression uses the followingsteps:

    y For each column, a value is identified that can be used to reduce the storage space for the values in each column.

    y A row that represents the prefix values for each column is created and stored in thecompression information (CI) structure that immediately follows the page header.

    y The repeated prefix values in the column are replaced by a reference to the correspondingprefix. If the value in a row does not exactly match the selected prefix value, a partialmatch can still be indicated.The following illustration shows a sample page of a table before and after prefix compression.The prefix is movedto the header, and the column values are changed to references to the prefix.

    y In the first column of the first row, the value 4b indicates that the first four characters of the prefix (aaab) are present for that row, and also the character b. This makes theresultant value aaabb, which is the original value.

  • 8/3/2019 Features in SQL2008(C612114)

    19/35

    P erform a nce En ha ncements - B a ckupCompression

    y Smaller than uncompressed backupy Increases backup speedy Increases CPU Usagey Compreesion ratio depends on

    y Type of datay Consistency of the data among rows on a pagey Data encrypted or noty Database is compressed or not

    y backupset history table will give you compreesion ratio

    SELECT backup_size/compressed_backup_size FROM msdb..backupsety Example statement to Backup database with compression option

    B A CKUP D A T A B A SE A dventureWorks TODISK='Z:\SQLServerBackups\ A dvWorksData.bak' WITH FORM A T, COMPRESSION

  • 8/3/2019 Features in SQL2008(C612114)

    20/35

    P erform a nce En ha ncements - Compression Dictionary compression

    y A pplied after Prefix Compressiony Dictionary compression searches for repeated values anywhere on the page, and

    stores them in the CI areay Not restricted to one column

    value 4b has been referenced from different columns of the page.

  • 8/3/2019 Features in SQL2008(C612114)

    21/35

    P erform a nce En ha ncements Filtered Indexes and Statistics

    y Use a predicate to create filtered indexes and statistics on a subset of rows in thetable

    y especially suited for queries that select from well-defined subsets of data, such ascolumns with mostly NULL values, columns with heterogeneous categories of values,and columns with distinct ranges of values

    Advantages over full-table indexes:y Improved query performance and plan quality

    Improves query performance and execution plan quality (because it is smaller and hasfiltered statistics. The filtered statistics are more accurate than full-table statisticsbecause they cover only the rows in the filtered index.

    y Reduced index maintenance costsReduces index maintenance costs because it is smaller and is only maintained when thedata in the index is affected. If a filtered index contains only the frequently affecteddata, the smaller size of the index reduces the cost of updating the statistics.

    y Reduced index storage costs Y ou can replace a full-table nonclustered index with multiple filtered indexes withoutsignificantly increasing the storage requirements.

  • 8/3/2019 Features in SQL2008(C612114)

    22/35

  • 8/3/2019 Features in SQL2008(C612114)

    23/35

    T-SQL Enha ncements Transact-SQL Row Constructors

    Transact-SQL is enhanced to allow multiple value inserts within a singleINSERT statement

    y Insert multiple rows through V A LUE clause of a single INSERT statementEx: INSERT INTO contacts V A LUES ('John Doe', '425-333-5321'), ('Jane Doe', '206-123-4567'), ('John Smith', '650-434-7869');

    y A ssignment operators: +=, -=, *=, /=UPD A TE Inventory SET quantity += s.quantity FROM Inventory A S iINNER JOIN Sales A S s ON i.id = s.id

    y Variable initialization during declarationDECL A ER @v int= 5;DECL A RE @v1 varchar(10) = xxxxx

  • 8/3/2019 Features in SQL2008(C612114)

    24/35

    T-SQL Enha ncements CON V ERT Function:

    Enhanced to allow conversions between binary and character hexadecimal values

    OPTIMIZE FOR Query H int Option Includes UNKNOWN V ariable V alue:The OPTIMIZE FOR query hint option is enhanced with the UNKNOWN syntax, whichspecifies that the Database Engine use statistical data to determine the value for one ormore local variables during query optimization, instead of the initial values. The syntaxcan be specified for all local variables in a query, or for one or more named local variables.

    INSERT EXECUTE Statements Can Execute Against Linked ServersSQL Server 2008 changes the transaction semantics of INSERT...EXECUTE statementsthat execute against a loopback linked server. In SQL Server 2005, this scenario is notsupported and causes an error. In SQL Server 2008, an INSERT...EXECUTE statement canexecute against a loopback linked server

  • 8/3/2019 Features in SQL2008(C612114)

    25/35

    T-SQL Enha ncements Date and Time

    SQL Server 2008 includes support for the ISO week-date system. For more information, seeD A TEP A RT (Transact-SQL).

    time , datetime2 and datetimeoffset provide more seconds precision. datetimeoffsetprovides time zone support for globally deployed applications.

  • 8/3/2019 Features in SQL2008(C612114)

    26/35

    T-SQL Enha ncements FILESTREAM Storage:

    FILESTRE A M storage enables SQL Server applications to store unstructured data, suchas documents and images, on the file system. This enables client applications to leveragethe rich streaming A PIs and performance of the file system while maintainingtransactional consistency between the unstructured data and corresponding structureddata Y ou can move the files from the location with out detaching database, but If you deletecorresponding data files, data access queries will fail, so don t delete the file from thestorage file stream group location

    Lock Escalation A

    new LOCK_ESC A

    L A

    TION option of A

    LTER T A

    BLE allows you to disable lockescalation on a table. On partitioned tables, you can configure locks to escalate to thepartitions instead of to the whole table. This option can improve concurrency by reducing lock contention when you are using partitioned tables

    A LTER T A BLE T1 SET (LOCK_ESC A L A TION = { A UTO | T A BLE | DIS A BLE })

  • 8/3/2019 Features in SQL2008(C612114)

    27/35

    T-SQL Enha ncements SQL Dependency Reporting Enhancements

    New catalog view and system functions to provide consistent and reliable SQLdependency to to report on cross-server, cross-database, and database SQL dependenciesfor both schema-bound and non-schema-bound objects

    y

    sys.sql_expression_dependenciesy sys.dm_sql_referencing_entitiesy sys.dm_sql_referenced_entities

  • 8/3/2019 Features in SQL2008(C612114)

    28/35

    T-SQL Enha ncements H ierarchyidDataType

    New system-provided data type to encapsulate hierarchical relationshipshierarchyid - Data type to create tablehierarchical methods - to query hierarchical data by using Transact-SQL

    Examples where the hierarchyid can be used:y A n organizational structurey A file systemy A set of tasks in a projecty A taxonomy of language termsy A graph of links between Web pages

    DDL Triggers and Event NotificationsExpanded to include numerous stored procedures that perform DDL-like operations

    y CRE A TE_ A PPLIC A TION_ROLEy CRE A TE_INDEX y CRE A TE_FUNCTIONy CRE A TE_PROCEDUREy A DD_ROLE_MEMBER y CRE A TE_SCHEM A y CRE A TE_D A T A B A SE

  • 8/3/2019 Features in SQL2008(C612114)

    29/35

    T-SQL Enha ncements Table H ints

    The FORCESEEK table hint is added to provide advanced query performance tuningoptions.

    The FORCESEEK table hint may be useful when the query plan uses a table or index

    scan operator on a table or view, but an index seek operator may be more efficient

    User Defined Table Typesy A new user defined typey A ligned with inlinedtable definition for table variablesy Can be used for declaring table variablesy Can define indexes and constraintsy New Catalog view for table types Sys.table_types

    CRE A TE T Y PE myT A S table (a int, b varchar(100))

  • 8/3/2019 Features in SQL2008(C612114)

    30/35

    T-SQL Enha ncements Table- V alued Parameters

    New parameter type that can reference user-defined table types

    Benefitsy Do not acquire locks for the initial population of data from a client.y Do not cause a statement to recompile.y Provide a simple programming model.y Enable you to include complex business logic in a single routine.y Reduce round trips to the server.y Can have a table structure of different cardinality.y A re strongly typed.y Enable the client to specify sort order and unique keys.

    Restrictionsy SQL Server does not maintain statistics on columns of table-valued parameters.y Table-valued parameters must be passed as input RE A DONL Y parameters to Transact-SQL

    routines. Y ou cannot perform DML operations such as UPD A TE, DELETE, or INSERT on a table- valued parameter in the body of a routine.

    y Y ou cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXECstatement. A table-valued parameter can be in the FROM clause of SELECT INTO or in theINSERT EXEC string or stored-procedure.

  • 8/3/2019 Features in SQL2008(C612114)

    31/35

    T-SQL Enha ncements Merge

    New DML statement that combines multiple DML operationsy Building block for more efficient ETLy Single Statement for Insert, Update and Delete functionality

    y If the Source Matches with Target then UPD A TEy If not match then INSERTy If Target not Matched then DELETE

  • 8/3/2019 Features in SQL2008(C612114)

    32/35

    T-SQL Enha ncements Change Data Capture

    y Enables change tracking on tables - Records Inserts, Deletes, Updatesy Sysadmin server role required to enable CDC on databasey To enable CDC on table db_owner role requiredy A ll CDC tables will be created under system tables.y Use system procedures to enable/disable CDC on database/tabley Disabling CDC on database will disable CDC on all the tablesy Use keep CDC option while restoring CDC enabled database if you want it to be enabled

    state in restored databasey sys.dm_cdc_errors contains error information for the previous 32 sessions

    Steps to enable CDC:y Enable CDC on database using sys.sp_cdc_enable_db

    - It will create some system CDC objects under system tablesy Enable CDC on the table you want to track changes using sys.sp_cdc_enable_table

    - It will create corresponding CT table under system tables- A lso while enabling CDC for the first table, it will create TWO jobs

    y cdc._Capturey cdc._Cleanup

  • 8/3/2019 Features in SQL2008(C612114)

    33/35

    T-SQL Enha ncements Change Data Capture

    y Provided following System stored procedures to implement, monitor & maintainCDC

    y sys.sp_cdc_enable_dby sys.sp_cdc_disable_dby sys.sp_cdc_enable_tabley sys.sp_cdc_disable_tabley sys.sp_cdc_add_joby sys.fn_cdc_get_min_lsny sys.fn_cdc_get_max_lsny sys.fn_cdc_map_lsn_to_timey sys.fn_cdc_map_time_to_lsny cdc.fn_cdc_get_all_changes_capture_instancey cdc.fn_cdc_get_net_changes_capture_instancey sys.dm_cdc_errors

  • 8/3/2019 Features in SQL2008(C612114)

    34/35

    Tools En ha ncementsSQL Server Management Studio has the following customer-requestedimprovements:

    y In the Query Editor window, you can query multiple servers at the sametime by opening query windows from registered server groups. The query results can be combined into a single results pane, or can be returned inseparate results panes. For more information, see A dministering MultipleServers Using Configuration Servers.

    y Y ou can access SQL Server Profiler from the Query Editor window, from theQuery menu, the Query Editor toolbar, or by pressing CTRL+ A LT+P.

    y Y ou can now open tables by using a Return Top n rows option.y Y ou can configure the number of rows that are returned when you are

    opening tables.y On the Tools/Option menu, you can specify the action that results by

    double-clicking tables in Object Explorer.y Y ou can block the table designer from re-creating tables when you are

    implementing design changes.

  • 8/3/2019 Features in SQL2008(C612114)

    35/35

    Questions?

    Thank Y

    ou