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