Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SQL Server 2008 for Developers


Published on

Slides from my talk on SQL Server 2008 for developers at OC Tech Days November 2008

Published in: Technology
  • Be the first to comment

SQL Server 2008 for Developers

  1. 1. Building Applications with SQL Server 2008 Lynn Langit
  2. 2. What Will We cover? <ul><li>SQL Server Spatial support </li></ul><ul><li>T-SQL Enhancements </li></ul><ul><li>Visual Studio integration </li></ul><ul><li>SQL CLR </li></ul><ul><li>Reporting Services </li></ul>
  3. 3. What is Spatial Data? <ul><li>Spatial data represents locations </li></ul><ul><ul><li>Which roads intersect property or each other? </li></ul></ul><ul><ul><li>How many stores/restaurants/houses/car dealerships are located within a geographical area? </li></ul></ul><ul><li>Represented by two primary data types </li></ul><ul><ul><li>Geometry : small areas where curvature of the Earth isn’t so relevant </li></ul></ul><ul><ul><ul><li>Flat Earth model or X, Y coordinates </li></ul></ul></ul><ul><ul><li>Geography : large areas where the curvature of the Earth does matter </li></ul></ul><ul><ul><ul><li>Round Earth model or Latitude and longitude coordinates </li></ul></ul></ul><ul><li>You query for location information as you would any SQL Server data type </li></ul><ul><ul><li>Data types dictated by the OpenGIS standard </li></ul></ul>
  4. 4. Representing Spatial Data <ul><li>Stored in proprietary binary format </li></ul><ul><ul><li>Can be input using simple text ( Parse methods convert text into internal storage format) </li></ul></ul><ul><ul><li>Represents areas using </li></ul></ul><ul><ul><ul><li>Points, Line strings, Polygons </li></ul></ul></ul><ul><ul><ul><li>Multi Points, Multi Line strings, Multi Polygons </li></ul></ul></ul><ul><ul><ul><li>Geom Collection </li></ul></ul></ul><ul><li>Areas must be defined in counter-clockwise direction, but Interior areas (“holes”) must be defined in clockwise direction </li></ul><ul><li>Spatial Reference ID (SRID) identifies ellipsoid used (flat/round, meters/feet) </li></ul><ul><ul><li>Only instances with like SRID can be directly compared </li></ul></ul>
  5. 5. Geographical Data <ul><li>GEOGRAPHY type has additional requirements </li></ul><ul><ul><li>Coordinate order is longitude/latitude </li></ul></ul><ul><ul><li>A single GEOGRAPHY object cannot span more than a logical hemisphere </li></ul></ul><ul><ul><ul><li>Will throw exceptions if too large </li></ul></ul></ul>
  6. 6. SQL Server Geospatial and Virtual Earth
  7. 7. Geo Spatial Links <ul><li>Practical uses for Geospatial data </li></ul><ul><li>Series on use of Geospatial data in SQL Server 2008 </li></ul><ul><li>OpenGIS standards </li></ul><ul><li>OGC Methods on Geography Instances </li></ul><ul><li>OGC Methods on Geometry Instances </li></ul>
  8. 8. Enhancements to T-SQL <ul><li>Table Value Parameters </li></ul><ul><li>New Date/Time types </li></ul><ul><li>Time zone awareness </li></ul><ul><li>New MERGE keyword </li></ul><ul><li>New shorthand notation </li></ul>
  9. 9. Table Value Parameters <ul><li>TVPs are used to insert/update multiple tables at one time </li></ul><ul><ul><li>MARS-like capability for writing </li></ul></ul><ul><li>ADO.NET updated to include support </li></ul><ul><ul><li>New parameter type: SqlDbType.Structured </li></ul></ul><ul><ul><li>MSDN documentation </li></ul></ul>
  10. 10. Dates and Time <ul><li>Several new types added </li></ul><ul><ul><li>datetime2 </li></ul></ul><ul><ul><li>date </li></ul></ul><ul><ul><li>time </li></ul></ul><ul><ul><li>datetimeoffset </li></ul></ul><ul><li>New functions added </li></ul><ul><ul><li>CONVERT </li></ul></ul><ul><ul><li>SYS* Functions </li></ul></ul><ul><ul><li>DATEDIFF </li></ul></ul>
  11. 11. MERGE <ul><li>MERGE allows for insert, update, delete with one keyword </li></ul><ul><ul><li>Merge two tables, source and target </li></ul></ul><ul><ul><li>Target table will be modified based on contents of source table </li></ul></ul><ul><li>Syntax and use can be complex! </li></ul><ul><ul><li>Review BOL for details </li></ul></ul>
  12. 12. Shorthand Notation <ul><li>Allows you to declare a variable and assign a value in one line of code </li></ul><ul><ul><li>More like contemporary programming languages, C# or Visual Basic .NET </li></ul></ul>
  13. 13. T-SQL Enhancements
  14. 14. Visual Studio Integration <ul><li>Enhanced project types </li></ul><ul><ul><li>SQL CLR Database projects </li></ul></ul><ul><ul><li>Analysis Services </li></ul></ul><ul><ul><ul><li>OLAP cubes </li></ul></ul></ul><ul><ul><ul><li>Data Mining Structures </li></ul></ul></ul><ul><ul><li>Integration Services </li></ul></ul><ul><ul><li>Reporting Services </li></ul></ul>
  15. 15. Entity Framework <ul><li>Essentially an OR/M tool </li></ul><ul><li>Models relational data using entities </li></ul><ul><ul><li>Can model any relational data source for data access (provider may be required) </li></ul></ul><ul><ul><li>Application-specific domain </li></ul></ul><ul><ul><li>You can work at a higher level of abstraction </li></ul></ul><ul><ul><li>Appropriate amount of information returned </li></ul></ul><ul><ul><li>Lazy-loaded </li></ul></ul><ul><li>What is an entity? </li></ul><ul><ul><li>Structurally like an object </li></ul></ul><ul><ul><ul><li>Has scalars and relationships </li></ul></ul></ul><ul><ul><ul><li>Has identity </li></ul></ul></ul><ul><ul><li>Represent nouns in your application domain </li></ul></ul><ul><li>Not tied specifically to SQL Server </li></ul>
  16. 16. Architecture
  17. 17. Visual Studio Integration
  18. 18. SQL CLR <ul><li>SQL Server has the ability to execute managed code </li></ul><ul><ul><li>Stored procedures </li></ul></ul><ul><ul><li>Functions </li></ul></ul><ul><ul><li>Aggregates </li></ul></ul><ul><ul><li>Table value functions </li></ul></ul><ul><ul><li>User-defined types </li></ul></ul><ul><ul><li>Triggers </li></ul></ul><ul><li>Visual Studio can manage both creation and deployment </li></ul><ul><li>SQL CLR is “off by default” for security reasons </li></ul><ul><ul><li>Must activate per database to enable </li></ul></ul><ul><li>Can be remotely debugged </li></ul><ul><li>With great power comes great responsibility </li></ul><ul><ul><li>Your code executes in the SQL Server processing stream </li></ul></ul>
  19. 19. Programming SQL CLR <ul><li>Visual Studio provides templates for the various SQL CLR constructs </li></ul><ul><ul><li>Uses Database project type </li></ul></ul><ul><ul><li>Simply “add new” like any other item you might add </li></ul></ul><ul><li>Metadata controls SQL Server behavior </li></ul><ul><ul><li>Attributes control programmatical type </li></ul></ul><ul><ul><ul><li>Microsoft.SqlServer.Server.SqlProcedure </li></ul></ul></ul><ul><ul><ul><li>Microsoft.SqlServer.Server.SqlFunction </li></ul></ul></ul><ul><ul><ul><li>Microsoft.SqlServer.Server.SqlUserDefinedAggregate </li></ul></ul></ul><ul><ul><ul><li>Microsoft.SqlServer.Server.SqlTrigger </li></ul></ul></ul><ul><ul><ul><li>Microsoft.SqlServer.Server.SqlUserDefinedType </li></ul></ul></ul><ul><li>You write your logic using a .NET-supported language </li></ul><ul><li>You work with other objects in the Microsoft.SqlServer.Server namespace to retrieve and return data </li></ul><ul><li>Very ADO.NET-like, but not ADO.NET </li></ul><ul><li>Can be assigned security levels </li></ul><ul><ul><li>Safe, External, Unsafe </li></ul></ul>
  20. 20. SQL CLR
  21. 21. Reporting Services <ul><li>SQL Server standard for reporting </li></ul><ul><ul><li>Managed enterprise reporting / Ad-hoc reporting / Embedded reporting / Web-based reporting </li></ul></ul><ul><li>Reports can be formatted in a variety of ways </li></ul><ul><ul><li>PDF / Word 2007 / HTML, custom </li></ul></ul><ul><li>Reports are exposed via a Web Service </li></ul><ul><ul><li>Can be integrated with SharePoint </li></ul></ul><ul><ul><li>Dependency on IIS removed (uses http.sys) </li></ul></ul><ul><li>Strong designer and wizard support in Visual Studio </li></ul><ul><ul><li>Can also use Report Builder </li></ul></ul><ul><li>Enhanced configuration and administration tool </li></ul><ul><li>SSRS available in SQL Server Express 2008 w/Adv Services </li></ul>
  22. 22. Programming Reports <ul><li>Design reports in Visual Studio 2008 SP1 </li></ul><ul><ul><li>Query for data </li></ul></ul><ul><ul><li>Assign query results to report </li></ul></ul><ul><ul><li>Design report style </li></ul></ul><ul><ul><ul><li>Colors </li></ul></ul></ul><ul><ul><ul><li>Fonts </li></ul></ul></ul><ul><ul><li>Deploy report </li></ul></ul><ul><ul><ul><li>Web Service </li></ul></ul></ul><ul><ul><ul><li>SharePoint Services </li></ul></ul></ul><ul><ul><ul><li>Report Viewer control in Visual Studio </li></ul></ul></ul><ul><li>Wizard available for initial report design </li></ul>
  23. 23. Reporting Services
  24. 24. For More Information <ul><li> </li></ul><ul><li> </li></ul>Pre-order it now
  25. 25. Surprise! <ul><li>Only for attendees of TechDays! </li></ul>