SQL Server 2008 R2 SP1 for Developers

1,857 views
1,763 views

Published on

deck from my talk for TechEd Africa Oct 2011

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,857
On SlideShare
0
From Embeds
0
Number of Embeds
483
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 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).aspxMerge 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.
  • Link for Entity Framework 4.2 - 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
  • Best book on Entity Framework - http://www.amazon.com/Programming-Entity-Framework-Julia-Lerman/dp/059652028X
  • Entity Framework Model Design surface and property window
  • Download tools here - http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
  • 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
  • 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.
  • Both
  • I add this slide at the end of EVERY presentation.
  • Both
  • We value your feedback – please submit your session evaluation to stand in line to win a Leatherman Kick Multi Tool sponsored by Microsoft Virtual Academy
  • SQL Server 2008 R2 SP1 for Developers

    1. 1. 17-20 OCTOBER 2011<br />DURBAN ICC<br />
    2. 2. SQL Server 2008 R2 for Developers<br />@LynnLangit & @LlewellynFalco<br />SESSION CODE: DAT312<br />
    3. 3. SQL Server 2008 R2 – So Many Features…<br />For Developers & DBAs<br /> Lifecycle Management<br />DACPACs (Data Tier Applications) <br />T-SQL enhancements<br />Geospatial data types<br /> XML data enhancements<br /> Filestreams (BLOBS)<br /> Sparse Columns<br />Filtered indices and full-text search<br /> Programmability<br />Entity Framework <br />
    4. 4. Data Tier Applications (DAC)<br /><ul><li>A single container for management for scripts++
    5. 5. Simplifies Development & Deployment
    6. 6. Has Version number for each container
    7. 7. Includes Policies (deployment prerequisites)
    8. 8. From SSMS, VS2010 and more
    9. 9. For SQL Server, SQL Azure</li></li></ul><li>Data-tier Application Lifecycle<br />Definition<br />Deployment artifact<br />Develop<br />Source code<br />Runtime<br />Container<br />Deploy<br />Upgrade<br />Contained database<br />Build<br />CREATETABLE Orders<br />(<br /> id INT,<br />ordTimeDATETIME,<br /> .<br /> .<br /> .<br />) -- ON OrdPS(ordTime)<br />CREATETABLE OrderEntr<br />(<br />DACPAC<br />CREATETABLEOrders<br />(<br /> id INT,<br />ordTimeDATETIME,<br /> .<br /> .<br /> .<br />) -- ON OrdPS(ordTime)<br />CREATETABLEOrderEntr<br />Reverse<br />Engineer<br />Extract<br />DACFx Services<br />
    10. 10. DACPAC<br />
    11. 11. DACPAC in SSMS 2010<br />
    12. 12. Upgrading with DACPAC<br />
    13. 13. Monitoring DACPACs via UCPs<br />
    14. 14. DACPAC project in Visual Studio 2010<br />
    15. 15. Creating DACPAC<br />Import schema from – script, database or DACPAC<br />(c) 2011 Microsoft. All rights reserved.<br />
    16. 16. DACPAC Project Template<br /><ul><li>Schema objects
    17. 17. Ordered by Schema
    18. 18. Also Database Level Objects
    19. 19. Scripts
    20. 20. Post-Deployment
    21. 21. Pre-Deployment
    22. 22. Data Generation Plans
    23. 23. Schema Comparisons</li></li></ul><li>Schema Comparison<br />(c) 2011 Microsoft. All rights reserved.<br />
    24. 24. Data Generation in DACPACs<br />(c) 2011 Microsoft. All rights reserved.<br />
    25. 25. Build…Deploy<br />(c) 2011 Microsoft. All rights reserved.<br />
    26. 26. “Smart T-SQL”<br />Smarter T-SQL<br />Geospatialtypes<br />XMLorFilestream<br />Full-text<br />SparseColumns<br />
    27. 27. T-SQL Enhancements<br /><ul><li>MERGE - Less scans through table & more query flexibility
    28. 28. GROUPING SETS</li></ul> - Less scans through table & more query flexibility<br />Table-valued strongly-typed parameters<br />- Less round trips to database<br />
    29. 29. Better T-SQL<br />
    30. 30. More T-SQL Enhancements<br />Sparse Column enhancements<br />XML enhancements<br />Geospatial enhancements<br />Filestream enhancements<br />Full-text enhancements<br />
    31. 31. Better Data types<br />
    32. 32. Entity Framework<br />What is EF?<br />Object/Relational Mapping (ORM) framework<br />How to use EF<br />query using LINQ<br />retrieve & manipulate data as strongly typed objects<br />LINQ to Entities provides IntelliSense <br />Why use EF?<br />work with relational data as domain-specific objects <br />eliminates the need for most of the data access plumbing code that you previously wrote<br />
    33. 33. EF Stack & Development Process Types<br /><ul><li>Database first
    34. 34. Model first
    35. 35. Code first (new in 4.1)</li></ul>(c) 2011 Microsoft. All rights reserved.<br />
    36. 36. Entity Framework<br />
    37. 37. EF Templates<br />
    38. 38.
    39. 39. EF Power Tools<br />(c) 2011 Microsoft. All rights reserved.<br />
    40. 40. POCO Classes - I<br />(c) 2011 Microsoft. All rights reserved.<br />
    41. 41. POCO Classes - II<br />(c) 2011 Microsoft. All rights reserved.<br />
    42. 42. Overriding Default Configuration<br />(c) 2011 Microsoft. All rights reserved.<br />
    43. 43. Using EF with MVC<br />(c) 2011 Microsoft. All rights reserved.<br />
    44. 44. EF 4.2<br />templates for using DbContext with Database First or Model First are now available on Visual Studio Gallery<br />(c) 2011 Microsoft. All rights reserved.<br />
    45. 45. Code to expose WCF service from EF<br />
    46. 46. Sample code to access EF data<br />
    47. 47. Entity Framework Profiling<br /><ul><li>Visual Studio Ultimate
    48. 48. Intellitrace
    49. 49. VS Profiler - article here
    50. 50. SQL Server Profiler
    51. 51. 3rd party tools
    52. 52. Article on Tracing - here</li></li></ul><li>You can use raw T-SQL <br />
    53. 53. New in SP1<br />•New or Improved Dynamic Management Views <br />--sys.dm_exec_query_stats --additional columns (long-running queries)<br />--new DMVs and XEvents on select performance counters are introduced to monitor OS configurations/resource conditions related to the SQL Server instance<br />•Improved FORCESEEK index hint & New FORCESCAN query hint <br />--syntax modified w/optional parameters allowing it to control the access method on the index even further<br />--FORCESCAN complements the FORCESEEK hint allowing specifying ‘scan’ as the access method to the index<br />•Improved DACPAC - (DAC Fx) improved database upgrades: <br />--(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<br />•New Disk space control for PowerPivot: <br />--Introduces two new configuration settings <br />--lets you determine how long cached data stays in the system<br />
    54. 54. SQL Server 2008 R2 – So Many Features…<br />For Developers & DBAs<br /> Lifecycle Management<br />DACPACs (Data Tier Applications) <br />T-SQL enhancements<br />Geospatial data types<br /> XML data enhancements<br /> Filestreams (BLOBS)<br /> Sparse Columns<br />Filtered indices and full-text search<br /> Programmability<br />Entity Framework <br />
    55. 55. Team Content – SQL Server<br /><ul><li>SQL CAT (Dev) blog - here
    56. 56. SQL Programmability blog - here
    57. 57. SQL Query Processing blog – here
    58. 58. MSDN Webcast: New T-SQL Programmability Features in SQL Server 2008 (Event ID: 1032357753)</li></li></ul><li>Resources<br />www.Develop.com<br /><ul><li>SQL Server (Dev, BI)
    59. 59. SQL Azure
    60. 60. Intro To TDD
    61. 61. Legacy Code</li></li></ul><li>TeachingKidsProgramming.org<br />Do a Recipe  Teach a Kid (Ages 10 ++)<br />Microsoft SmallBasic  Free Courseware (recipes)<br />
    62. 62. Contact Information<br />@LlewellynFalcohttp://LlewellynFalco.Blogspot.com<br />http://www.approvaltests.com<br />@LynnLangit<br />http://www.LynnLangit.com<br />
    63. 63. http://microsoftvirtualacademy.com<br />Submit your session evaluation for a chance to win! <br />Sponsored by MVA<br />
    64. 64. Creating<br />the future<br />together<br />

    ×