Ing. Eduardo Castro, PhD
ecastro@mswindowscr.org
References
 What's new in SQL11 by Roger Noble
 DAT303 SQL Server “Denali” High Availability: The next generation high availability
    solution
   http://blogs.technet.com/b/dataplatforminsider/archive/2010/11/12/analysis-
    services-roadmap-for-sql-server-denali-and-beyond.aspx
   http://prologika.com/CS/blogs/blog/archive/2010/11/15/bism-column-store.aspx
   http://msdn.microsoft.com/en-us/library/ms174518.aspx
   http://www.jenstirrup.com/2010/11/project-crescent-in-denali-bism-summary.html
   http://blogs.msdn.com/b/ssdt/archive/2010/11/08/welcome.aspx
   http://msdn.microsoft.com/en-us/data/gg427686
   http://www.msteched.com/2010/Europe/DAT314
   http://www.msteched.com/2010/NorthAmerica/BIE304
   http://ecn.channel9.msdn.com/o9/te/Europe/2010/pptx/bin303.pptx
   DAT303 SQL Server “Denali” High Availability
References
•   What’s new BOL - http://msdn.microsoft.com/en-us/library/bb500435(v=SQL.110).aspx
•   HADR - http://msdn.microsoft.com/en-us/library/ff877884(SQL.110).aspx &
    http://www.brentozar.com/archive/2010/11/sql-server-denali-database-mirroring-rocks/
•   Atlanta - https://www.microsoftatlanta.com/
•   T-SQL - Tobias Ternström
•   Sequence Generators - http://msdn.microsoft.com/en-us/library/ff878058(SQL.110).aspx &
    http://www.sergeyv.com/blog/archive/2010/11/09/sql-server-sequence-generators.aspx
•   Contained Databases - http://sqlblog.com/blogs/aaron_bertrand/archive/2010/11/16/sql-server-v-next-
    denali-contained-databases.aspx
•   Data Quality Services - Denise Draper
•   Column Store - http://download.microsoft.com/download/8/C/1/8C1CE06B-DE2F-40D1-9C5C-
    3EE521C25CE9/Columnstore Indexes for Fast DW QP SQL Server 11.pdf
•   UDM & BISM - http://blogs.technet.com/b/dataplatforminsider/archive/2010/11/12/analysis-services-
    roadmap-for-sql-server-denali-and-beyond.aspx &
    http://prologika.com/CS/blogs/blog/archive/2010/11/13/business-intelligence-semantic-model-the-
    good-the-bad-and-the-ugly.aspx
•   SSIS - Matt Masson
•   SSIS Resolve References - http://www.sqlservercentral.com/blogs/dknight/archive/2010/11/15/ssis-
    denali-resolve-references.aspx
•   BISM vs SSAS - http://cwebbbi.wordpress.com/2010/11/14/pass-summit-day-2-the-aftermath/
•   Crescent - http://www.jenstirrup.com/2010/11/project-crescent-when-is-it-best_1327.html
T-SQL Enhancements
 Robust Discovery of Result Set Metadata (replacing
  SET FMTONLY)
 Improved Error Handling
   Introduces the THROW, which allows us to re-throw an
    exception caught in an exception handling block
 FileTable
 Sequence Generators
 Paging Construct
 Support for UTF-16
   Collations can be used with the data types: nchar,
    nvarchar, and sql_variant
T-SQL Result Sets
    Suppose that you need to write code against SQL Server
     that uses result sets returned from stored procedures
     and dynamic batches
    You need a guarantee that the result sets will have very
     specific metadata. if the shape of the result is different
     than what you expect, you need it to fail.



http://www.sqlmag.com/blogs/puzzled-by-t-sql/tabid/1023/entryid/76198/Denali-T-SQL-
at-a-Glance-EXECUTE-WITH-RESULT-SETS.aspx
T-SQL Result Sets
 You can specify the new option with the EXECUTE
 statement when executing a stored procedure or a
 dynamic batch

   EXECUTE <batch_or_proc> WITH <result_sets_option>;
T-SQL Result Sets
 RESULT SETS UNDEFINED
    this is the default, meaning that never mind what’s the
     shape of the result sets

 RESULT SETS NONE
    you have a guarantee that no result set will be returned. If
     a result set is returned, an error is generated and the
     batch terminates
T-SQL Result Sets
 RESULT SETS <definition>

   Specify the metadata of one or more result sets, and get a
    guarantee that the result sets and their number will
    match the metadata defined in the RESULT SETS clause
Demo
SQL Server Denali THROW
command
 The THROW command can be invoked in two main
 ways:

   Without any parameters within the CATCH block of a
    TRY/CATCH construct. This will essentially re-throw
    the original error.
   With parameters to throw a user defined error.
 Demo

    http://www.sqlmag.com/blogs/puzzled-by-t-sql/tabid/1023/entryid/76190/Denali-T-
                                                      SQL-at-a-Glance-THROW.aspx
T-SQL Enhancements File Table
FileTable
• A merging of the FILESTREAM and HierarchyID
• Can store files and folders
• FileTables are accessed via windows share
• Created table has predefined schema

CREATE TABLE DocumentStore AS FileTable WITH
FileTable_Directory Document
   FILESTREAM_ON FILESTREAMGroup1;
T-SQL Enhancements Sequence Generator


SEQUENCE
• Generates a predicatble number of values
• Global
• Can be
  ascending, descending, minimum, maximum and
  cycle
• Supports getting a range via
  sp_sequence_get_range
T-SQL Enhancements Sequence Generator


CREATE SEQUENCE ComWinSchema.IdSequence
     AS INT
     START WITH 10000 INCREMENT BY 1;
GO

INSERT INTO ComunidadMembers (MemberId, Name)
VALUES (NEXT VALUE FOR ComWinSchema.IdSequence, 'Juan');

INSERT INTO ComunidadAdmin (AdminId, Name)
VALUES (NEXT VALUE FOR ComWinSchema.IdSequence, ‘Juan');
T-SQL Enhancements Paging
  -- Before Denali
  WITH a AS (
  SELECT
  ROW_NUMBER() OVER (ORDER BY Name)
  AS RowNum ...
  )
  SELECT * FROM a
  WHERE a BETWEEN 11 AND 20
  ORDER BY RN ORDER BY RowNum;


http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx
T-SQL Enhancements Paging
-- In Denali

SELECT...
ORDER BY ...
OFFSET 10 ROWS
FETCH NEXT 10 ROWS ONLY

 Not a performance improvement, there for ease of use
 Perf is similar to using ROW_NUMBER
Demo
VertiPaq
 VertiPaq Storage Engine

  Lots of cheap RAM => In-memory storage
  Column-oriented data compression > 10:1
  Support for column-oriented DAX queries
Column Store Indexes
• PowerPivot in SQL Server
• An index is created across columns instead
  of rows
• Can give a massive query performance
  increase
• Read only
• Reduced IO
• Compressed
• Not a NoSQL implementation / alternative
Denali Columnstore Indexes
 Denali introduces a new type of index called the
 columnstore.

 This new type of index is built up on the values across
 columns instead of traditional row based indexes.

 As data tends to be less unique across a column it
 allows the columnstore to efficiently compress and
 store data.
Denali Columnstore Indexes

 The columnstore is currently read-only, however it can be
  updated via dropping and recreating the index, or switching in a
  partition.

 Due to the ability to compress and keep the index in memory
  the Columnstore can give massive (10x, 100x, 1000x…) increase in
  speed to warehouse queries

 Not all queries can benefit and some can regress. In general
  typical star join queries found in a Data Warehouse when only a
  portion of the columns are selected will get the biggest benefit.
Denali Columnstore Indexes
 
   http://download.microsoft.com/download/8/C/1/8
 C1CE06B-DE2F-40D1-9C5C-
 3EE521C25CE9/Columnstore%20Indexes%20for%20Fa
 st%20DW%20QP%20SQL%20Server%2011.pdf
Column Store Index




 http://download.microsoft.com/download/8/C/1/8C1CE06B-DE2F-40D1-9C5C-3EE521C25CE9/
 Columnstore%20Indexes%20for%20Fast%20DW%20QP%20SQL%20Server%2011.pdf
TSQL in SQL Server 2012

TSQL in SQL Server 2012

  • 1.
    Ing. Eduardo Castro,PhD ecastro@mswindowscr.org
  • 2.
    References  What's newin SQL11 by Roger Noble  DAT303 SQL Server “Denali” High Availability: The next generation high availability solution  http://blogs.technet.com/b/dataplatforminsider/archive/2010/11/12/analysis- services-roadmap-for-sql-server-denali-and-beyond.aspx  http://prologika.com/CS/blogs/blog/archive/2010/11/15/bism-column-store.aspx  http://msdn.microsoft.com/en-us/library/ms174518.aspx  http://www.jenstirrup.com/2010/11/project-crescent-in-denali-bism-summary.html  http://blogs.msdn.com/b/ssdt/archive/2010/11/08/welcome.aspx  http://msdn.microsoft.com/en-us/data/gg427686  http://www.msteched.com/2010/Europe/DAT314  http://www.msteched.com/2010/NorthAmerica/BIE304  http://ecn.channel9.msdn.com/o9/te/Europe/2010/pptx/bin303.pptx  DAT303 SQL Server “Denali” High Availability
  • 3.
    References • What’s new BOL - http://msdn.microsoft.com/en-us/library/bb500435(v=SQL.110).aspx • HADR - http://msdn.microsoft.com/en-us/library/ff877884(SQL.110).aspx & http://www.brentozar.com/archive/2010/11/sql-server-denali-database-mirroring-rocks/ • Atlanta - https://www.microsoftatlanta.com/ • T-SQL - Tobias Ternström • Sequence Generators - http://msdn.microsoft.com/en-us/library/ff878058(SQL.110).aspx & http://www.sergeyv.com/blog/archive/2010/11/09/sql-server-sequence-generators.aspx • Contained Databases - http://sqlblog.com/blogs/aaron_bertrand/archive/2010/11/16/sql-server-v-next- denali-contained-databases.aspx • Data Quality Services - Denise Draper • Column Store - http://download.microsoft.com/download/8/C/1/8C1CE06B-DE2F-40D1-9C5C- 3EE521C25CE9/Columnstore Indexes for Fast DW QP SQL Server 11.pdf • UDM & BISM - http://blogs.technet.com/b/dataplatforminsider/archive/2010/11/12/analysis-services- roadmap-for-sql-server-denali-and-beyond.aspx & http://prologika.com/CS/blogs/blog/archive/2010/11/13/business-intelligence-semantic-model-the- good-the-bad-and-the-ugly.aspx • SSIS - Matt Masson • SSIS Resolve References - http://www.sqlservercentral.com/blogs/dknight/archive/2010/11/15/ssis- denali-resolve-references.aspx • BISM vs SSAS - http://cwebbbi.wordpress.com/2010/11/14/pass-summit-day-2-the-aftermath/ • Crescent - http://www.jenstirrup.com/2010/11/project-crescent-when-is-it-best_1327.html
  • 4.
    T-SQL Enhancements  RobustDiscovery of Result Set Metadata (replacing SET FMTONLY)  Improved Error Handling  Introduces the THROW, which allows us to re-throw an exception caught in an exception handling block  FileTable  Sequence Generators  Paging Construct  Support for UTF-16  Collations can be used with the data types: nchar, nvarchar, and sql_variant
  • 5.
    T-SQL Result Sets  Suppose that you need to write code against SQL Server that uses result sets returned from stored procedures and dynamic batches  You need a guarantee that the result sets will have very specific metadata. if the shape of the result is different than what you expect, you need it to fail. http://www.sqlmag.com/blogs/puzzled-by-t-sql/tabid/1023/entryid/76198/Denali-T-SQL- at-a-Glance-EXECUTE-WITH-RESULT-SETS.aspx
  • 6.
    T-SQL Result Sets You can specify the new option with the EXECUTE statement when executing a stored procedure or a dynamic batch EXECUTE <batch_or_proc> WITH <result_sets_option>;
  • 7.
    T-SQL Result Sets RESULT SETS UNDEFINED  this is the default, meaning that never mind what’s the shape of the result sets  RESULT SETS NONE  you have a guarantee that no result set will be returned. If a result set is returned, an error is generated and the batch terminates
  • 8.
    T-SQL Result Sets RESULT SETS <definition>  Specify the metadata of one or more result sets, and get a guarantee that the result sets and their number will match the metadata defined in the RESULT SETS clause
  • 9.
  • 10.
    SQL Server DenaliTHROW command  The THROW command can be invoked in two main ways:  Without any parameters within the CATCH block of a TRY/CATCH construct. This will essentially re-throw the original error.  With parameters to throw a user defined error.
  • 11.
     Demo http://www.sqlmag.com/blogs/puzzled-by-t-sql/tabid/1023/entryid/76190/Denali-T- SQL-at-a-Glance-THROW.aspx
  • 12.
    T-SQL Enhancements FileTable FileTable • A merging of the FILESTREAM and HierarchyID • Can store files and folders • FileTables are accessed via windows share • Created table has predefined schema CREATE TABLE DocumentStore AS FileTable WITH FileTable_Directory Document FILESTREAM_ON FILESTREAMGroup1;
  • 13.
    T-SQL Enhancements SequenceGenerator SEQUENCE • Generates a predicatble number of values • Global • Can be ascending, descending, minimum, maximum and cycle • Supports getting a range via sp_sequence_get_range
  • 14.
    T-SQL Enhancements SequenceGenerator CREATE SEQUENCE ComWinSchema.IdSequence AS INT START WITH 10000 INCREMENT BY 1; GO INSERT INTO ComunidadMembers (MemberId, Name) VALUES (NEXT VALUE FOR ComWinSchema.IdSequence, 'Juan'); INSERT INTO ComunidadAdmin (AdminId, Name) VALUES (NEXT VALUE FOR ComWinSchema.IdSequence, ‘Juan');
  • 15.
    T-SQL Enhancements Paging -- Before Denali WITH a AS ( SELECT ROW_NUMBER() OVER (ORDER BY Name) AS RowNum ... ) SELECT * FROM a WHERE a BETWEEN 11 AND 20 ORDER BY RN ORDER BY RowNum; http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx
  • 16.
    T-SQL Enhancements Paging --In Denali SELECT... ORDER BY ... OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY  Not a performance improvement, there for ease of use  Perf is similar to using ROW_NUMBER
  • 17.
  • 18.
    VertiPaq  VertiPaq StorageEngine  Lots of cheap RAM => In-memory storage  Column-oriented data compression > 10:1  Support for column-oriented DAX queries
  • 19.
    Column Store Indexes •PowerPivot in SQL Server • An index is created across columns instead of rows • Can give a massive query performance increase • Read only • Reduced IO • Compressed • Not a NoSQL implementation / alternative
  • 20.
    Denali Columnstore Indexes Denali introduces a new type of index called the columnstore.  This new type of index is built up on the values across columns instead of traditional row based indexes.  As data tends to be less unique across a column it allows the columnstore to efficiently compress and store data.
  • 21.
    Denali Columnstore Indexes The columnstore is currently read-only, however it can be updated via dropping and recreating the index, or switching in a partition.  Due to the ability to compress and keep the index in memory the Columnstore can give massive (10x, 100x, 1000x…) increase in speed to warehouse queries  Not all queries can benefit and some can regress. In general typical star join queries found in a Data Warehouse when only a portion of the columns are selected will get the biggest benefit.
  • 22.
    Denali Columnstore Indexes  http://download.microsoft.com/download/8/C/1/8 C1CE06B-DE2F-40D1-9C5C- 3EE521C25CE9/Columnstore%20Indexes%20for%20Fa st%20DW%20QP%20SQL%20Server%2011.pdf
  • 23.
    Column Store Index http://download.microsoft.com/download/8/C/1/8C1CE06B-DE2F-40D1-9C5C-3EE521C25CE9/ Columnstore%20Indexes%20for%20Fast%20DW%20QP%20SQL%20Server%2011.pdf

Editor's Notes

  • #13 The FileTable feature in SQL Server Code-Named “Denali” allows SQL Server-based enterprise applications to store unstructured file system data, such as files and directories, on a special FileTable in a relational database. This allows an application to integrate its storage and data management systems, and provides integrated SQL Server services (such as full-text search) over unstructured data and metadata, along with easy policy management and data administration.
  • #20 Traditional indexes store data across rowsColumn index stores data across a columnAllows for faster queries + better compressionCannot easily insert, update or delete data
  • #24 Vertipaq technology that is shared in PowerPivot and Analysis ServicesBetter compression and performance gains due to redundancy across columnsHeavily optimised for star join queries