Exciting Features for SQL Devs in SQL 2012
Upcoming SlideShare
Loading in...5
×
 

Exciting Features for SQL Devs in SQL 2012

on

  • 627 views

 

Statistics

Views

Total Views
627
Views on SlideShare
627
Embed Views
0

Actions

Likes
1
Downloads
17
Comments
1

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Exciting Features for SQL Devs in SQL 2012 Exciting Features for SQL Devs in SQL 2012 Presentation Transcript

    • EXCITING FEATURES FORSQL DEVS IN SQL 2012Brij Bhushan Mishra
    • About Me• Brij Bhushan Mishra• Microsoft ASP.NET/IIS MVP• Former CodeProject MVP• Blogger/Author/Speaker• http://brijbhushan.net• @brij_bhushan• brij.mishra@outlook.com
    • SQL-2012 Enticing features• Contained database• Always On• Column Store Indexes• Visual Studio integration with Management Studio• TSQL Enhancements
    • Row Store• Relational Data is stored as row wise which further getsstored in page with page size 8KB in HardDisk asRow StoreColumn 1 Column 2 Column 3 Column 4 Column 5 Column 1 Column 2 Column 3 Column 4 Column 5Page 1 Page 2Column 1Hits multiple rows to fetch the data
    • Columnstore index• Pages stores column data and Columns are heavilycompressedColumn 1 Column 1 Column 4 Column 4Page 2Page 1• Removes redundancy and provide faster searchLimitations• 1 Table can have only one 1 Columnstore index• After creating Columnstore index table cannot be updated
    • TSQL Enhancement• Sequence Objects• Data Paging• Error handling• Exec Procs with Result Set• Metadata discovery• Logical functions and String Functions• Conversion functions• Date Time functions• Analytic Functions LEAD() and LAG()
    • Sequence Objects• A user defined object that returns a sequence of numericvalues• Similar is available with Oracle• Unique to database, not to a Table (Not like IdentityColumn)• Can be used anywhere not specific to a Table• Does not support TransactionParametersType (Integer) MAXVALUESTART WITH <constant> CYCLE | NO CYCLEINCREMENT BY <constant> CACHE <constant> | NO CACHEMINVALUEDEMO
    • Data Paging• One of the most used features in Applications• Most of the application implements Paging at Applicationlevel (not a database level)• Currently for Database level Paging• Retrieve data using ROW_NUMBER function• Temp Tables• Other options..• SQL 2012 simplified this• Need to set the offset command• The number of Rows that required to be fetched by using “FETCH”commandDEMO
    • Error handling• SQL Server 2005 introduced try/catch (But throw wasmissing)• But to send the error to client, required to useRAISEERROR• Throw is added (similar like C# or vb.NET)• Now do not required to add a entry in Sys.Messages table• The original exception is sent to the Client.DEMO
    • EXEC Stored Proc with Result Sets• Can specify a new option with the EXECUTE statementasEXECUTE <proc> WITH <result_set_option>• Allows to change the column names and data types inResult SetsDEMO
    • Metadata Discovery• Earlier we used SET FMTONLY ON that is used to returnthe metadata only (Not the actual data)• Very helpful, in scenarios where we cannot predict theresult set.• Two new Proc and equivalent DMV introduced• sp_describe_first_result_set• sp_describe_undeclared_parameters• sys.dm_exec_describe_first_result_set• sys.dm_exec_describe_first_result_set_for_objectDEMO
    • Logical and String Functions• IIF• Takes a boolean expression and returns one of the two given values.• Shorthand of Case expression• Can be nested upto 10 levels• CHOOSE• Returns a value from the list based on the provided Index• If does not find then returns null• DataType is returned based on the precedence• FORMAT• FORMAT function for locale-aware formatting of date/time andnumber values as strings• CONCAT• Concatenates two or more strings
    • Conversion Functions• PARSE• Parse a string and try to convert in provided data type.• Uses the .NET CLR• Raise an error if not able to convert it• TRY_PARSE• Similar to parse but returns null if unable to parse• Also uses the .NET CLR• TRY_CONVERT• Similar to Convert but returns null if unable to parseDEMO
    • DateTime functions• EOMONTH (start_date)• DATEFROMPARTS (year, month, day)• DATETIME2FROMPARTS (year, month, day, hour,minute, seconds, fractions, precision)• DATETIMEFROMPARTS (year, month, day, hour, minute,seconds, milliseconds)• DATETIMEOFFSETFROMPARTS (year, month, day,hour, minute, seconds, fractions, hour_offset,minute_offset, precision)• SMALLDATETIMEFROMPARTS (year, month, day, hour,minute)• TIMEFROMPARTS (hour, minute, seconds, fractions,precision)
    • Analytic function Lead() and Lag()• LAG() – Access the data in the previous row from thesame result set without self join• Parameters• scalar_expression• Offset• Default• Over([partition_by_clause] order_by_clause) *• Lead() - Access the data in the subsequent row from thesame result se• scalar_expression• Offset• Default• Over([partition_by_clause] order_by_clause) *.
    • Thank you• http://brijbhushan.net• @brij_bhushan• brij.mishra@outlook.com