SQL Server2012 Enhancements

364 views
288 views

Published on

SQL Server 2012 enhancements

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
364
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

SQL Server2012 Enhancements

  1. 1. By Abhishek Sur Microsoft MVP, Client App DevFollow us at Twitter @abhi2434 & @sqlservergeeks
  2. 2. Why SQL Server 2012 ? Always On Contained Databases Column Store Indexes Visual Studio integration with Management Studio TSQL Enhancements 2
  3. 3. 3
  4. 4. The ConceptRowStore Page Int Varchar Datetime float • ColumnStore reduces redundancy of data and compression as the data type remains same for the entire page. • All data for a single column could be retrieved from a non clusteredColumnstore Page index page.Int Int Int Int float float float float Limitation • 1 Table can have one columnstore index. 4
  5. 5. 5
  6. 6. Introducing SQL Server 2012 Transact-SQLImprovements• Query Pagination• OVER Clause Windowing• Sequences• Metadata Discovery• Enhanced Function Library• General T-SQL-Related Enhancements
  7. 7. Query Pagination• Common application requirement to retrieve rows − For a given page − For a given page length− Our Options ??? − Retrieve all and filter in application end − Retrieve data using Row_NUMBER function − Any other options ?− Denali gives better option for pagination
  8. 8. OVER Clause Windowing• Some existing queries do not optimize well• Example: Details of orders and days since previous order of each product-- Traditional approachSELECT rs.ProductKey,rs.OrderDateKey,rs.SalesOrderNumber,rs.OrderDateKey- (SELECT TOP 1 prev.OrderDateKeyFROM dbo.FactResellerSales AS prevWHERE rs.ProductKey=prev.ProductKeyAND prev.OrderDateKey<=rs.OrderDateKeyAND prev.SalesOrderNumber<rs.SalesOrderNumberORDER BY prev.OrderDateKey DESC,prev.SalesOrderNumber DESC)AS DaysSincePrevOrderFROM dbo.FactResellerSales AS rsORDER BY rs.ProductKey,rs.OrderDateKey,rs.SalesOrderNumber;
  9. 9. OVER Clause Windowing• Some existing queries do not optimize well• Example: Details of orders and days since previous order of each product-- Windowed approachSELECT ProductKey,OrderDateKey,SalesOrderNumber,OrderDateKey-LAG(OrderDateKey)OVER (PARTITION BY ProductKeyORDER BY OrderDateKey,SalesOrderNumber)AS DaysSincePrevOrderFROM dbo.FactResellerSales AS rsORDER BY ProductKey,OrderDateKey,SalesOrderNumber;
  10. 10. OVER Clause Windowing• Some existing queries do not optimize well• Example: Details of orders and days since previous order of each product
  11. 11. Sequences• User-defined object• Not tied to any particular table• Not restricted to being used in a single table• Eases migration from other database engines• Does not support Transaction
  12. 12. Metadata Discovery• Applications need to determine metadata associated with code batches or stored procedures• New functionality provided as both system stored procedures and via DMVs − DMVs make the metadata easy to consume in a relational query − Additional DMV option for passing an object ID (helpful for stored procedures or triggers)System Stored Procedure Equivalent DMVsp_describe_first_result_set sys.dm_exec_describe_first_result_set sys.dm_exec_describe_first_result_set_for_object• EXECUTE supports a WITH RESULT SETS clause
  13. 13. Enhanced Function Library• New functions added Conversion Date and Time Logical and String Analytic PARSE DATEFROMPARTS CHOOSE CUME_DIST TRY_PARSE TIMEFROMPARTS IIF PERCENTILE_DIST TRY_CONVERT DATETIMEFROMPARTS CONCAT PERCENTILE_CONT DATETIME2FROMPARTS FORMAT PERCENT_RANK SMALLDATETIMEFROMPARTS FIRST_VALUE DATETIMEOFFSETFROMPARTS LAST_VALUE EOMONTH LEAD LAG• LOG function now supports an optional base
  14. 14. General T-SQL-Related Enhancements• THROW statement − Can throw user-errors − Can rethrow any errors in a CATCH block (including system errors)• Extended Events supports many new events − Mostly relating to memory page allocation
  15. 15. WWW.KOLKATAGEEKS.COMWWW.SQLSERVERGEEKS.COM

×