SQL Server 2008 R2 Features for Developers

  • 4,270 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to like this
No Downloads

Views

Total Views
4,270
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
44
Comments
1
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • DAT302 Developer Features in SQL Server 2008 R2Session Type: Breakout Session Level: 300Track: Database and BI (DAT)Speaker(s): Lynn LangitIn this session, you will learn about new features of SQL Server 2008 R2 for Developers. Topics covered will include the following: --use of Entity Framework--DACPACs (Data Tier Applications) for developer--using the Geospatial datatypes--understanding when and how to use T-SQL enhancements--working with XML data--working with Filestreams (BLOBS)--using sparse columns--usingfiltered indices and full-text search
  • Whitepaper MSDN on DacPac - http://msdn.microsoft.com/en-us/library/ff381683(SQL.100).aspx
  • To be able to UPGRADE database (dacpac) must be registered
  • TechNet article - http://technet.microsoft.com/en-us/library/cc721270(SQL.100).aspx
  • Merge is only one scan.Grouping sets greatly reduce the amount of data being processed.TVPs allow for more batch/set based operations and so great improvements for write time and network round time latency.Data Warehouse performance can use multiple bitmap filters in 2008 you can have multiple bitmap iterators. This is for the star join queries.Reference:http://www.sqlskills.com/blogs/bobb/2007/12/27/PlanFreezingAndOtherPlanGuideEnhancementsInSQLServer2008.aspx  and http://www.sqlskills.com/blogs/bobb/2007/12/28/MoreHintsAvailableToPlanGuidesInSQLServer2008.aspx
  • Sparse columns - http://msdn.microsoft.com/en-us/library/cc280604.aspxSparse columns are ordinary columns that have an optimized storage for null values. Sparse columns reduce the space requirements for null values at the cost of more overhead to retrieve nonnull values. Consider using sparse columns when the space saved is at least 20 percent to 40 percent. Sparse columns and column sets are defined by using the CREATE TABLE or ALTER TABLE statements.CREATE TABLE dbo.DocumentStore (DocIDint PRIMARY KEY, Title varchar(200) NOT NULL, ProductionSpecificationvarchar(20) SPARSE NULL, ProductionLocationsmallint SPARSE NULL, MarketingSurveyGroupvarchar(20) SPARSE NULL ) ; GO Sparse columns can be used with column sets and filtered indexes:Column setsINSERT, UPDATE, and DELETE statements can reference the sparse columns by name. However, you can also view and work with all the sparse columns of a table that are combined into a single XML column. This column is called a column set. For more information about column sets, see Using Column Sets.Filtered indexesBecause sparse columns have many null-valued rows, they are especially appropriate for filtered indexes. A filtered index on a sparse column can index only the rows that have populated values. This creates a smaller and more efficient index. For more information, see Filtered Index Design Guidelines.Sparse columns and filtered indexes enable applications, such as Windows SharePoint Services, to efficiently store and access a large number of user-defined properties by using SQL Server.Filtered Index http://msdn.microsoft.com/en-us/library/cc280372.aspxGeospatial – article on ‘flat’ in a round world - http://technet.microsoft.com/en-us/library/cc749633(SQL.100).aspxFilestream - http://technet.microsoft.com/en-us/library/cc949109(SQL.100).aspx – Conclusion:FILESTREAM storage is not appropriate in all cases. Based on prior research and FILESTREAM feature behavior, BLOB data of size 1 MB and larger that will not be accessed through Transact-SQL is best suited to storing as FILESTREAM data. Consideration must also be given to the update workload, as any partial update to a FILESTREAM file will generate a complete copy of the file. With a particularly heavy update workload, the performance may be such that FILESTREAM is not appropriate.Filetable in Denali builds on Filestream (http://msdn.microsoft.com/en-us/library/ff929144(v=sql.110).aspx) – Conclusion: The FileTable feature brings support for the Windows file namespace and compatibility with Windows applications to the file data stored in SQL Server. FileTable lets an application integrate its storage and data management components, and provides integrated SQL Server services - including full-text search and semantic search - over unstructured data and metadata. In other words, you can store files and documents in special tables in SQL Server called FileTables, but access them from Windows applications as if they were stored in the file system, without making any changes to your client applications.
  • What is EF? Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals.About 4.1 – video - http://msdn.microsoft.com/en-us/data/hh134816Download - http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8363•The DbContext API is a simplified abstraction over ObjectContext and a number of other types that were included in previous releases of the ADO.NET Entity Framework. The DbContext API surface is optimized for common tasks and coding patterns.•Code First is a new development pattern for the ADO.NET Entity Framework and provides an alternative to the existing Database First and Model First patterns. Code First is focused around defining your model using C#/Visual Basic .NET classes, these classes can then be mapped to an existing database or be used to generate a database schema. Additional configuration can be supplied using Data Annotations or via a fluent API.
  • Write Class (es)Add reference to EntityFramework package v4.1 (can use NuGet) > EntityFrameworkdllDefine a class that derives from DbContext, define the entities as DBSets
  • 4. Use the context5. Populate the context6. Add the data to an Entitity7. SaveChanges to the context8. Can (optionally) foreach over the Entity to see the values added at this point (just use Console output)NOTE – in 4.1 – you can create only – changes require that you drop the database created by EF. This will be addressed in the next CTP via UPGRADE or GENERATE, depending on the type of change requested (this will be called EntityFramework.SqlMigrations – dll is named EntityFramework.Migrations.)This creates a local database with inferred object names (all can be changed)To change:You can use Data Annotations on your POCO classes, i.e. [Required] for not nullable -OR-Override the OnModelCreating method in the context intitializer and use the ‘fluent’ API to associate the specific characteristics with your model’s properties (i.e. columns), such as ‘modelBuild.Entity<Product>().Property(p=>p.Name).IsRequired’Note: in this release 4.1 stored procs are NOT supported for code-first
  • Note: in this release 4.1, pluggable naming conventions are NOT supported
  • http://nuget.org/List/Packages/EntityFramework.Preview
  • Can also download add-in for VS2010 – adds menus for DBContext - http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19dEntity Framework -- http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=83634.1 adds DbContext
  • NOT for code-first yet
  • Download here - http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26727•Dynamic Management Views for increased supportability: sys.dm_exec_query_stats DMV is extended with additional columns to improve supportabilities over troubleshooting long-running queries. New DMVs and XEvents on select performance counters are introduced to monitor OS configurations and resource conditions related to the SQL Server instance. •ForceSeek for improved querying performance :Syntax for FORCESEEK index hint has been modified to take optional parameters allowing it to control the access method on the index even further. Using old style syntax for FORCESEEK remains unmodified and works as before. In addition to that, a new query hint, FORCESCAN has been added. It complements the FORCESEEK hint allowing specifying ‘scan’ as the access method to the index. No changes to applications are necessary if you do not plan to use this new functionality.•Data-tier Application Component Framework (DAC Fx) for improved database upgrades: The new Data-tier Application (DAC) Framework v1.1 and DAC upgrade wizard enable the new in-place upgrade service for database schema management. The new in-place upgrade service will upgrade the schema for an existing database in SQL Azure and the versions of SQL Server supported by DAC. A DAC is an entity that contains all of the database objects and instance objects used by an application. A DAC provides a single unit for authoring, deploying, and managing the data-tier objects. For more information, see Designing and Implementing Data-tier Applications. •Disk space control for PowerPivot: This update introduces two new configuration settings that let you determine how long cached data stays in the system. In the new Disk Cache section on the PowerPivot configuration page, you can specify how long an inactive database remains in memory before it is unloaded. You can also limit how long a cached file is kept on disk before it is deleted.
  • Lynn

Transcript

  • 1.
  • 2. SQL Server 2008 R2 for Developers
    Lynn Langit
    Sr. Developer Evangelist
    Microsoft
    SESSION CODE: # DAT302
    (c) 2011 Microsoft. All rights reserved.
  • 3. SQL Server 2008 R2 – So Many Features…
    DACPACs (Data Tier Applications)
    T-SQL enhancements
    Geospatial data types
    XML data enhancements
    Filestreams (BLOBS)
    Sparse Columns
    Filtered indices and full-text search
    Entity Framework
    For Developers
  • 4. Database Development Pain Points
    Developers
    SQL expertise
    Maintain script libraries
    Versioned deployments
    Keeping development/test/production synchronized
    Database administrators (DBAs)
    Hand reconcile upgrade scripts
    Schema/data portability
    Security/containment
    Management at scale
  • 5. Data Tier Applications (DAC)
    • Defines all of the Database Engine schema and instance objects
    • 6. A single unit of management
    • 7. Simplifies Development
    • 8. Deployment
    • 9. Management lifecycle
    • 10. Version numbers
    • 11. Contains policies that define the deployment prerequisite
  • Data-tier Application Lifecycle
    Runtime
    Container
    Definition
    Deployment artifact
    Develop
    Source code
    Contained database
    CREATETABLE Orders
    (
    id INT,
    ordTimeDATETIME,
    .
    .
    .
    ) -- ON OrdPS(ordTime)
    CREATETABLE OrderEntr
    (
    Deploy
    Upgrade
    Build
    DACPAC
    CREATETABLEOrders
    (
    id INT,
    ordTimeDATETIME,
    .
    .
    .
    ) -- ON OrdPS(ordTime)
    CREATETABLEOrderEntr
    Reverse
    Engineer
    Extract
    DACFx Services
  • 12. Working with DACPACs
    For developers in Visual Studio 2010
    For DBAs in SQL Server Management Studio
    Supports SQL Server
    Supports SQL Azure
    Client-side framework
    Via a database model (in memory)
    Services to get ‘in/out’ of model
    (c) 2011 Microsoft. All rights reserved.
  • 13. DACPAC project in Visual Studio 2010
  • 14. Creating DACPAC
    (c) 2011 Microsoft. All rights reserved.
    Import schema from – script, database or DACPAC
  • 15. DACpac Project Template
  • Schema Comparison
    (c) 2011 Microsoft. All rights reserved.
  • 23. Data Generation in DACPACs
    (c) 2011 Microsoft. All rights reserved.
  • 24. Build…Deploy
    (c) 2011 Microsoft. All rights reserved.
  • 25. DACPAC
  • 26. Monitoring DACPACs via UCPs
  • 27. DACPAC  SQL Server Database Project
    (c) 2011 Microsoft. All rights reserved.
  • 28. Utilizing SQL Server “data types”
    “Smart T-SQL”
    Geospatial types
    XML or Filestream
    Full-text
    Sparse Columns
  • 29. Key T-SQL Enhancements
    Table-Valued Parameters
    T-SQL Assign and Increment Operators
    Row Constructors
    Grouping Sets
    MERGE statement
    Dependency Views
    Performance Enhancements
  • 30. T-SQL Performance Enhancements
    MERGE and GROUPING SETS improvements
    Less scans through table
    Table-valued parameters improvements
    Less round trips to database
    Improvements for data warehouse queries
    Earlier predicate filtering
    Multiple bitmap iterators per query
    Plan Guide Improvements
    Easier to create plan guides
    Plan guides on DML statements
    Also: Object reference tracking makes schema and procedural code versioning less error-prone
  • 31. Better T-SQL
  • 32. Other Data type enhancements
    Sparse Column enhancements?
    XML enhancements?
    Geospatial enhancements?
    Filestream enhancements?
    Full-text enhancements?
  • 33. Better Data types
  • 34. T-SQL Improvements Recap
    Strongly typed table-valued parameters -- helps the database round trip problem
    Grouping Sets -- allow arbitrary group by clauses for subtotals and totals
    MERGE statement -- allows set-to-set comparison and multiple deterministic operations (ANSI standard compliance with extensions)
    Object reference tracking -- makes schema and procedural code versioning less error-prone
  • 35. Entity Framework
    What is EF?
    Object/Relational Mapping (ORM) framework
    How to use EF
    query using LINQ
    retrieve & manipulate data as strongly typed objects
    LINQ to Entities provides IntelliSense
    Why use EF?
    work with relational data as domain-specific objects
    eliminates the need for most of the data access plumbing code that you previously wrote
  • 36. EF Stack & Development Process Types
    • Database first
    • 37. Model first
    • 38. Code first (new in 4.1)
    (c) 2011 Microsoft. All rights reserved.
  • 39. EF Templates
  • 40. POCO Classes - I
    (c) 2011 Microsoft. All rights reserved.
  • 41. POCO Classes - II
    (c) 2011 Microsoft. All rights reserved.
  • 42. Overriding Default Configuration
    (c) 2011 Microsoft. All rights reserved.
  • 43. EF Power Tools
    (c) 2011 Microsoft. All rights reserved.
  • 44. Using EF with MVC
    (c) 2011 Microsoft. All rights reserved.
  • 45. EF 4.2
    (c) 2011 Microsoft. All rights reserved.
    templates for using DbContext with Database First or Model First are now available on Visual Studio Gallery
  • 46. Entity Framework
  • 47. Code to expose WCF service from EF
  • 48. Sample code to access EF data
  • 49. Entity Framework Profiling
    • Visual Studio Ultimate
    • 50. Intellitrace
    • 51. VS Profiler - article here
    • 52. SQL Server Profiler
    • 53. 3rd party tools
    • 54. Article on Tracing - here
  • You can use raw T-SQL
  • 55. New in SP1
    (c) 2011 Microsoft. All rights reserved.
    •New or Improved Dynamic Management Views
    --sys.dm_exec_query_stats --additional columns (long-running queries)
    --new DMVs and XEvents on select performance counters are introduced to monitor OS configurations/resource conditions related to the SQL Server instance
    •Improved FORCESEEK index hint & New FORCESCAN query hint
    --syntax modified w/optional parameters allowing it to control the access method on the index even further
    --FORCESCAN complements the FORCESEEK hint allowing specifying ‘scan’ as the access method to the index
    •Improved DACPAC - (DAC Fx) improved database upgrades:
    --(DAC) Framework v1.1 and DAC upgrade wizard enable the new in-place upgrade service --New in-place upgrade service will upgrade the schema for an existing database in SQL Azure and the versions of SQL Server supported by DAC
    •New Disk space control for PowerPivot:
    --Introduces two new configuration settings that let you determine how long cached data stays in the system
  • 56. SQL Server 2008 R2 – So Many New Features…
    For Developers
    DACPACs (Data Tier Applications)
    T-SQL enhancements
    Geospatial data types
    XML data enhancements
    Filestreams (BLOBS)
    Sparse Columns
    Filtered indices and full-text search
    Entity Framework 4.1
  • 57. Next Steps
    LEARN MORE ABOUT SQL SERVER 2008 R2
    http://www.microsoft.com/sqlserver/2008/en/us/whats-new.aspx
    DOWNLOAD SQL SERVER 2008 R2
    http://www.microsoft.com/sqlserver/2008/en/us/r2.aspx
    UPGRADE TO SQL SERVER 2008 R2
    http://www.microsoft.com/sqlserver/2008/en/us/how-to-buy.aspx
  • 58. Related Content
    MSDN Webcast: New T-SQL Programmability Features in SQL Server 2008 (Event ID: 1032357753)
  • 59. Team Content – SQL Server
    • SQL CAT (Dev) blog - here
    • 60. SQL Programmability blog - here
    • 61. SQL Query Processing blog - here
  • Other Related Content
    Lynn’s Resources
    http://blogs.msdn.com/SoCalDevGal
    Twitter - @llangit
    http://www.slideshare.net/lynnlangit
  • 62. www.TeachingKidsProgramming.org
    • Do a Recipe  Teach a Kid (Ages 10 ++)
    • 63. Microsoft SmallBasic  Free Courseware (recipes)
  • Resources
    www.msteched.com/Australia
    Sessions On-Demand & Community
    www.microsoft.com/australia/learning
    Microsoft Certification & Training Resources
    http:// technet.microsoft.com/en-au
    Resources for IT Professionals
    http://msdn.microsoft.com/en-au
    Resources for Developers
    (c) 2011 Microsoft. All rights reserved.
  • 64. Complete an Evaluation online and enter to WIN these prizes!
    <Prizes & Process TBC>
    (c) 2011 Microsoft. All rights reserved.
  • 65. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
    The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.