What's New for Developers in SQL Server 2008?

5,175 views

Published on

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
  • Very good article to know about new features of SQL 2008
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
5,175
On SlideShare
0
From Embeds
0
Number of Embeds
424
Actions
Shares
0
Downloads
293
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide
  • What's New for Developers in SQL Server 2008?

    1. 1. Eric Nelson Developer Evangelist [email_address] – I will reply http://blogs.msdn.com/ericnel - tends to be about .NET and data http://blogs.msdn.com/goto100 - all about Visual Basic http://twitter.com/ericnel - pot luck :-) http://blogs.msdn.com/ukdevevents The ONLY LINK you need!
    2. 2. <ul><li>First PC – ZX80 in 1980 (then BBC Micro , Atari 520STFM and Macintosh LC ) </li></ul><ul><li>First computer job... FORTAN in 1986 </li></ul><ul><li>Wrote most LOC on... Unix using C </li></ul><ul><li>Favourite IDE of all time ... GNU Emacs </li></ul><ul><li>Joined Microsoft DRG in 1996 </li></ul><ul><li>Early adoption work on ASP, SQL 6.5, MTS ... </li></ul><ul><li>Went “Back to development” in July 2008 – in VB </li></ul><ul><li>I Geek to Live (not Live to Geek) </li></ul><ul><li>I am editor of the UK MSDN Flash </li></ul><ul><li>I am fascinated by ALT.NET values and practices </li></ul>http://blogs.msdn.com/ukdevevents The ONLY LINK you need!
    3. 3. <ul><li>I live near Bath with wife, 2 kids, 1 dog (and many pet graves in the garden) </li></ul><ul><li>I originally intended to be a naval officer </li></ul><ul><li>I am very shy...seriously! </li></ul>http://blogs.msdn.com/ukdevevents The ONLY LINK you need!
    4. 4. <ul><li>Sign up to the MSDN Flash </li></ul><ul><ul><li>Feedback, vote etc </li></ul></ul><ul><li>Technical articles for the UK MSDN Flash </li></ul><ul><ul><li>400 to 500 words </li></ul></ul><ul><li>War stories around VB6 to .NET </li></ul><ul><li>Your right (or left) arm in the air </li></ul><ul><ul><li>NB: not all the time  </li></ul></ul>
    5. 5. <ul><li>Give a flavour of the </li></ul><ul><li>new “stuff” in SQL Server 2008 </li></ul><ul><li>for development </li></ul><ul><li>and </li></ul><ul><li>an insight into the direction </li></ul><ul><li>we are taking with data </li></ul>
    6. 6. <ul><li>TSQL Enhancements </li></ul><ul><ul><li>SQL-2006 </li></ul></ul><ul><ul><li>Major and minor </li></ul></ul><ul><li>Beyond Relational </li></ul><ul><ul><li>Filestream </li></ul></ul><ul><ul><li>Full text search </li></ul></ul><ul><ul><li>Spatial </li></ul></ul><ul><ul><li>Semi-structured </li></ul></ul><ul><li>Futures* </li></ul><ul><ul><li>Object Relational Management </li></ul></ul><ul><ul><li>SQL Data Services </li></ul></ul>In one hour
    7. 7. <ul><li>Released August 6 th 2008 </li></ul><ul><li>Many versions! </li></ul>
    8. 9. <ul><ul><li>Date & Time </li></ul></ul>Date types <ul><ul><li>Table value constructor using VALUES clause </li></ul></ul><ul><ul><li>MERGE </li></ul></ul><ul><ul><li>Table Types and Table Value Parameters </li></ul></ul><ul><ul><li>GROUPING SET </li></ul></ul>SQL language <ul><ul><li>IDE improvements </li></ul></ul><ul><ul><li>Compound assignment operators </li></ul></ul><ul><ul><li>Declaring and initializing variables </li></ul></ul>Delighters
    9. 10. <ul><li>IDE Improvements </li></ul><ul><ul><li>Debugging is back! </li></ul></ul><ul><ul><li>Intellisense has made it in </li></ul></ul><ul><li>Compound Assignment operators: +=, -=, *=, /= </li></ul><ul><li>Variable initialization during declaration </li></ul>UPDATE Inventory SET quantity += s.quantity FROM Inventory AS i INNER JOIN Sales AS s ON i.id = s.id DECLAER @v int = 5 ; DECLARE @v1 varchar(10) = ‘xxxxx’;
    10. 12. <ul><li>Insert multiple rows based on values in a single INSERT statement </li></ul><ul><li>SQL 2006 standard compatible </li></ul>INSERT INTO dbo.Customers(custid, companyname, phone, address)   VALUES   (1, 'cust 1', '(111) 111-1111', 'address 1'),   (2, 'cust 2', '(222) 222-2222', 'address 2'),   (3, 'cust 3', '(333) 333-3333', 'address 3'),   (4, 'cust 4', '(444) 444-4444', 'address 4'),   (5, 'cust 5', '(555) 555-5555', 'address 5');
    11. 13. <ul><li>Single statement that combines multiple DML operations </li></ul><ul><li>Operates on a join between source and target </li></ul><ul><li>SQL-2006 compliant </li></ul>UPDATE TGT SET TGT.quantity = TGT.quantity + SRC.quantity, TGT.LastTradeDate = SRC.TradeDate FROM dbo.StockHolding AS TGT JOIN dbo.StockTrading AS SRC ON TGT.stock = SRC.stock; INSERT INTO dbo.StockHolding (stock, lasttradedate, quantity) SELECT stock, tradedate, quantity FROM dbo.StockTrading AS SRC WHERE NOT EXISTS (SELECT * FROM dbo.StockHolding AS TGT WHERE TGT.stock = SRC.stock); MERGE INTO dbo.StockHolding AS TGT USING dbo.StockTrading AS SRC ON TGT.stock = SRC.stock WHEN MATCHED AND (t.quantity + s.quantity = 0) THEN DELETE WHEN MATCHED THEN UPDATE SET t.LastTradeDate = s.TradeDate, t.quantity += s.quantity WHEN NOT MATCHED THEN INSERT VALUES (s.Stock,s.TradeDate,s.Quantity) Pre-SQL 2008 SQL 2008
    12. 14. Source Table (Stock Trading) Target Table (Stock Holding) Merged Table (Stock Holding) INSERT UPDATE DELETE
    13. 15. <ul><li>A new user defined type - Table </li></ul><ul><ul><li>Can define indexes and constraints </li></ul></ul><ul><li>Can be used for </li></ul><ul><ul><li>declaring table variables </li></ul></ul><ul><ul><li>Input parameters of Table type on SPs/Functions </li></ul></ul><ul><li>Optimized to scale and perform better for large data </li></ul><ul><li>Behaves like BCP inside server </li></ul><ul><li>In ADO.NET SqlDbType.Structured </li></ul>CREATE TYPE myTableType AS TABLE (id INT, name NVARCHAR(100),qty INT); CREATE PROCEDURE myProc (@tvp myTableType READONLY ) AS …
    14. 16. <ul><li>Define multiple groupings in the same query </li></ul><ul><li>Produces a single result set that is equivalent to a UNION ALL of differently grouped rows </li></ul><ul><li>SQL 2006 standard compatiable </li></ul>SELECT customerType,Null as TerritoryID,MAX(ModifiedDate) FROM Sales.Customer GROUP BY customerType UNION ALL SELECT Null as customerType,TerritoryID,MAX(ModifiedDate) FROM Sales.Customer GROUP BY TerritoryID order by TerritoryID SELECT customerType,TerritoryID,MAX(ModifiedDate) FROM Sales.Customer GROUP BY GROUPING SETS ((customerType), (TerritoryID)) order by customerType Pre-SQL 2008 SQL 2008
    15. 19. CREATE TABLE Employee { FirstName VARCHAR(10), LastName VARCHAR(10), Birthday DATE , … } SELECT Birthday AS BirthDay FROM Employee INSERT INTO T (datetime2_col) VALUES (‘ 1541 -01-01’) INSERT INTO T (time_col) VALUES (’12:30:29 .1176548 ’) CREATE TABLE online-purchase-order { item-id int, item-name VARCHAR(30), qty int, purchase-time datetimeoffset, … } // For value ‘ 2005-09-08 12:20:19.345 -08:00 ’ INSERT INTO online-purchase-order VALUES (…., ‘ 2005-09-08 12:20:19.345 -08:00’ ,..) <ul><ul><li>Large year range (1~9999) </li></ul></ul><ul><ul><li>Storage saving </li></ul></ul><ul><ul><li>Easy programming </li></ul></ul>DATE <ul><ul><li>Large or optional precision (0 ~ 100ns) </li></ul></ul><ul><ul><li>Easy programming </li></ul></ul>TIME <ul><ul><li>Large year range </li></ul></ul><ul><ul><li>Large or optional precision </li></ul></ul>DATETIME2 <ul><ul><li>Datetime + time zone offset </li></ul></ul><ul><ul><li>UTC enabled </li></ul></ul><ul><ul><li>Easy programming </li></ul></ul>DATETIME OFFSET
    16. 22. SQL Server 2005 SQL Server 2008 <ul><li>HierarchyID </li></ul><ul><li>Large UDTs </li></ul><ul><li>Sparse Columns </li></ul><ul><li>Wide Tables </li></ul><ul><li>Filtered Indices </li></ul><ul><li>XML Upgrades </li></ul><ul><li>User Defined Types </li></ul><ul><li>XML Data Type and Functions </li></ul><ul><li>Full Text Indexing </li></ul><ul><ul><li>Filestream </li></ul></ul><ul><ul><li>Integrated FTS </li></ul></ul><ul><ul><li>Fully supported Geometry and Geography data types and Functions </li></ul></ul>Relational Semi Structured Documents & Multimedia Spatial
    17. 23. Remote BLOB Storage FILESTREAM Storage SQL BLOB Documents & Multimedia Use File Servers DB Application BLOB Dedicated BLOB Store DB Application BLOB Store BLOBs in Database DB Application BLOB Store BLOBs in DB + File System Application BLOB DB
    18. 24. <ul><li>Storage Attribute on VARBINARY(MAX) </li></ul><ul><li>Works with integrated FTS </li></ul><ul><li>Unstructured data stored directly in the file system (requires NTFS) </li></ul><ul><li>Dual Programming Model </li></ul><ul><ul><li>TSQL (Same as SQL BLOB) </li></ul></ul><ul><ul><li>Win32 Streaming APIs with T-SQL transactional semantics </li></ul></ul><ul><li>Advantages </li></ul><ul><ul><li>Integrated Manageability </li></ul></ul><ul><ul><li>SQL Server Security Stack </li></ul></ul><ul><ul><li>Dual model </li></ul></ul>Documents & Multimedia Store BLOBs in DB + File System Application BLOB DB
    19. 26. <ul><li>Full-Text Engine and Indexes fully integrated </li></ul><ul><ul><li>Catalog, index and stopword lists now inside the database </li></ul></ul><ul><li>Better performance in many common scenarios </li></ul><ul><ul><li>Make mixed queries perform and scale </li></ul></ul><ul><ul><li>Optimizer has knowledge about FT index </li></ul></ul><ul><ul><li>SELECT * FROM candidates WHERE CONTAINS(resume,’”SQL Server”’) AND ZipCode = ‘98052’ </li></ul></ul>Documents & Multimedia
    20. 27. Populating an index of 20million rows of 1k data on identical hardware (time in minutes) 2 min 1 min Documents & Multimedia
    21. 28. <ul><li>Proliferation of geographical data </li></ul><ul><ul><li>GPS Systems, Virtual Earth, Live Search Maps etc </li></ul></ul><ul><ul><li>New opportunities for spatially aware apps </li></ul></ul><ul><li>Storage and retrieval of spatial data using standard SQL </li></ul><ul><ul><li>New Spatial Data Types + methods + indexes </li></ul></ul><ul><ul><ul><li>geometry - Flat Earth (Planar) </li></ul></ul></ul><ul><ul><ul><li>geography - Round Earth (Geodetic) </li></ul></ul></ul><ul><li>Offers full set of Open Geospatial Consortium components </li></ul>Spatial
    22. 30. 1 2 3 4 5 1 3 4 5 2 // Create a Filtered Indexes // Sparse column Create Table Products(Id int, Type nvarchar(16)…, Resolution int SPARSE , ZoomLength int SPARSE ); // Filtered Indices Create Index ZoomIdx on Products(ZoomLength) where Type = ‘Camera’; // HierarchyID CREATE TABLE [dbo].[Folder] ( [FolderNode] HIERARCHYID NOT NULL UNIQUE, [Level] AS [FolderNode].GetLevel() PERSISTED, [Description] NVARCHAR(50) NOT NULL ); HierarchyID Store arbitrary hierarchies of data and efficiently query them Large UDTs No more 8K limit on User Defined Types Sparse Columns Optimized storage for sparsely populated columns Wide Tables Support thousands of sparse columns Filtered Indices Define indices over subsets of data in tables Relational Semi Structured
    23. 34. <ul><li>What is it? </li></ul><ul><ul><li>Technique for working with relational tables as if they were objects in memory </li></ul></ul><ul><ul><li>Intention is to hide away the complexity of the underlying tables and give a uniform way of working with data </li></ul></ul><ul><li>Why use it? </li></ul><ul><ul><li>Productivity </li></ul></ul><ul><ul><li>Retain database independence </li></ul></ul><ul><li>Which ORM? </li></ul><ul><ul><li>There are many ORMs for .NET developers already in existence. E.g. </li></ul></ul><ul><ul><ul><li>LLBLGen Pro http://www.llblgen.com/ </li></ul></ul></ul><ul><ul><ul><li>Nhibernate http://www.hibernate.org/343.html </li></ul></ul></ul><ul><ul><ul><li>EntitySpaces http://www.entityspaces.net/Portal/Default.aspx </li></ul></ul></ul>
    24. 35. <ul><li>LINQ to SQL </li></ul><ul><ul><li>.NET Framework 3.5, Nov 2007 </li></ul></ul><ul><ul><li>Only SQL Server </li></ul></ul><ul><ul><li>Simple </li></ul></ul><ul><ul><li>Easy to learn and master </li></ul></ul><ul><li>LINQ to Entities ( ADO.NET Entity Framework ) </li></ul><ul><ul><li>.NET Framework 3.5 SP1, Aug 2008 </li></ul></ul><ul><ul><li>“ Any” RDBMS </li></ul></ul><ul><ul><li>Complex </li></ul></ul><ul><ul><li>Easy to learn, hard to master </li></ul></ul><ul><ul><li>Strategic </li></ul></ul>
    25. 38. HTTP (AtomPub) Clients (Tools, Libraries, etc) SQL Data Services ADO.NET Data Services Framework SQL Server (On premises data service) (Cloud data service)
    26. 39. Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Data Access Lib SDS Runtime REST / SOAP Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server Mgmt. Services Distributed Data Fabric SQL Server
    27. 40. <ul><li>Unit of geo-location and billing </li></ul><ul><li>Tied to DNS name </li></ul><ul><li>Collection of Containers </li></ul>
    28. 41. <ul><li>Entity properties may differ in type and instance </li></ul>
    29. 46. <ul><li>Drop me an email if I confused you about anything! </li></ul><ul><ul><li>[email_address] </li></ul></ul><ul><li>http:// blogs.msdn.com/ UKDevEvents </li></ul><ul><ul><li>Post event resources for all Microsoft UK developer focused sessions </li></ul></ul><ul><li>The team </li></ul><ul><ul><li>Eric Nelson http://blogs.msdn.com/ericnel </li></ul></ul><ul><ul><li>Mike Ormond http://blogs.msdn.com/mikeormond </li></ul></ul><ul><ul><li>Mike Taulty http://mtaulty.com </li></ul></ul>

    ×