Using New Data Types In2008


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Using New Data Types In2008

  1. 1. Using New Data Types in 2008 Andrew Couch UK Access User Group ASC associates
  2. 2. Flow of Presentation <ul><li>Data types and products </li></ul><ul><li>Share Point : Access & SQL Server </li></ul><ul><li>SQL Server : Access & Visual Studio </li></ul><ul><li>SQL Server New Data Types </li></ul><ul><li>Updating Data & Multi-user Issues </li></ul><ul><li>Summary </li></ul>
  3. 3. Why are we interested in Data Types? <ul><li>What we do with data </li></ul><ul><ul><li>Exchange </li></ul></ul><ul><ul><ul><li>Converting and exchanging data between products </li></ul></ul></ul><ul><ul><li>Applications that present data </li></ul></ul><ul><ul><ul><li>Linking applications to back-end data sources </li></ul></ul></ul><ul><ul><li>Applications that maintain data </li></ul></ul><ul><ul><ul><li>updating data with applications linked to back-end data source </li></ul></ul></ul>
  4. 4. Which Products will we consider? <ul><li>Products </li></ul><ul><ul><li>Access </li></ul></ul><ul><ul><ul><li>Application and data source </li></ul></ul></ul><ul><ul><li>SQL Server </li></ul></ul><ul><ul><ul><li>data source and application components, also report services </li></ul></ul></ul><ul><ul><li>Share Point </li></ul></ul><ul><ul><ul><li>Application and data source (SQL Server) </li></ul></ul></ul><ul><ul><li>Visual Studio </li></ul></ul><ul><ul><ul><li>Application </li></ul></ul></ul>
  5. 5. What Data Types do the Products support? Access (2007) GUID Multi-value fields Share Point (2003) see next slide SQL Server (2008) Visual Studio (2005/8) n prefix for Unicode
  6. 6. Share Point (2003)
  7. 7. Share Point under the hood Data is held in the AllUserData table which has a generic set of fields, nvarchar1,nvarchar2......Text1,Text2.........
  8. 8. Access to Share Point Data Types; MOSS
  9. 9. Access (2007) & Share Point <ul><li>Attachments (share point lists) </li></ul><ul><li>Multi-value fields (share point lists) </li></ul>
  10. 10. Share Point a Data/Object Model; WSS <ul><li>Object Model Enhancements for Visual Studio </li></ul><ul><ul><li> </li></ul></ul><ul><li>Ethan’s blog, Inspecting The SharePoint Content Database </li></ul><ul><ul><li> </li></ul></ul><ul><li>Architectural Overview of Windows SharePoint Services </li></ul><ul><ul><li> </li></ul></ul>
  11. 11. Access to SQL Server Data Type Mappings <ul><li>Yes/No (boolean) : bit </li></ul><ul><ul><li>Access True -1, SQL Server True 1; also SQL Server boolean is tri-state 0, 1 and NULL </li></ul></ul><ul><li>Text : varchar or nvarchar or char or nchar </li></ul><ul><li>Date/Time : datetime </li></ul><ul><li>Currency : money </li></ul><ul><li>Autonumber : int (identity property) </li></ul><ul><li>OLE Object : image, varbinary, filestream </li></ul><ul><li>Memo : text or varchar(max) </li></ul><ul><li>Number : various mappings </li></ul>
  12. 12. Access Yes/No Data
  13. 13. Yes/No (without a default) Translated To SQL Server
  14. 14. Access Memo and OLE Data Types
  15. 15. Access Using SQL Server 2000 IMAGE and TEXT Data Types
  16. 16. Visual Studio Editing Records in DetailsView; issues with Text Data Type
  17. 17. Visual Studio and Image/OLE Data issues with Image Data Type
  18. 18. Access & SQL Server 2005 Varchar(max) and Varbinary(max)
  19. 19. Visual Studio DetailsView now works for Updates when using Varchar(max)
  20. 20. Visual Studio, Images and OLE still a problem with Varbinary(max) some people would suggest that image data should not directly held in the database and instead a text link is used to point to an external image file which works around this issue
  21. 21. Mini-summary <ul><li>Access to SQL Server </li></ul><ul><ul><li>MEMO to VARCHAR(max) or TEXT </li></ul></ul><ul><ul><li>OLE to IMAGE or VARBINARY(max), FILESTREAM ? </li></ul></ul><ul><li>Visual Studio </li></ul><ul><ul><li>VARCHAR(max) a better choice </li></ul></ul><ul><ul><li>OLE/IMAGE data doesn’t work for bound controls </li></ul></ul>
  22. 22. SQL Server (2005) <ul><li>XML data type </li></ul><ul><ul><li>office requires program code using new SQL Native Client drivers to manipulate this </li></ul></ul><ul><li>varchar(max), nvarchar(max) </li></ul><ul><ul><li>advantages for programmers as can use as a variable (not possible with older text data type) </li></ul></ul><ul><li>varbinary(max) </li></ul>
  23. 23. Date & Time Data <ul><li>IBM DB2 </li></ul><ul><ul><li>DATE, TIME and TIMESTAMP date range 0001-01-01 to 9999-12-31 </li></ul></ul><ul><li>Oracle </li></ul><ul><ul><li>DATE (includes time), TIMESTAMP, date range January 1 4713 BC to 9999-12-31 </li></ul></ul><ul><li>SQL Server (2000/2005) </li></ul><ul><ul><li>DATETIME, SMALLDATETIME, date range 1753-01-01 to 9999-12-31 for DATETIME, when no date given defaults to 1st January 1900 </li></ul></ul><ul><li>Access – DATE/TIME </li></ul><ul><ul><li>date range 1-1-100 to 9999-12-31,when no date given defaults to 30th December 1899 and hides date </li></ul></ul><ul><li>SQL Server (2008) </li></ul><ul><ul><li>DATE, TIME,DATETIME2, DATETIMEOFFSET range 0001-01-01 00:00:00:0000000 to 9999-12-31 23:59:59:9999999 </li></ul></ul>
  24. 24. Access allowing Updates to new Date and Time Data Types
  25. 25. Searching <ul><li>some limitations where fields are strings </li></ul>
  26. 26. Controlling Time Precision
  27. 27. SQL Server (2008) <ul><li>Filestream </li></ul><ul><ul><li>Unstructured large object data </li></ul></ul><ul><li>DATE and TIME </li></ul><ul><ul><li>Dates from 01/01/0001 to 31/12/9999 </li></ul></ul><ul><ul><li>Times accurate to 00:00:00:0000000 </li></ul></ul><ul><li>DATETIME2 and DATEOFFSET </li></ul><ul><ul><li>New combined date and time data types with higher accuracy, Combines above, offset type includes time-zone data </li></ul></ul><ul><li>HIERARCHYID </li></ul><ul><ul><li>Optimised for data hierarchies (special functions) </li></ul></ul><ul><li>GEOGRAPHY and GEOMETRY </li></ul><ul><ul><li>.NET-based spatial data </li></ul></ul><ul><ul><li>First deals with round-earth co-ordinates, second uses a flat-earth style of co-ordinates </li></ul></ul><ul><ul><li>Special functions </li></ul></ul>
  28. 28. Geography <ul><li>It comes as no surprise that this renders in a binary type format and you can’t edit it </li></ul><ul><li>Stored procedures and pass through queries to the rescue! </li></ul>
  29. 29. With a little Magic
  30. 30. Geography Methods
  31. 31. Timestamps & Multiple Users <ul><li>SQL </li></ul><ul><li>Server </li></ul>Overwrite data when changed Optimistic row versioning Timestamp checking Visual Studio does not utilise timestamps on bound controls the new LINQ will support timestamp concurrency
  32. 32. Access Row Versioning & Timestamps Row Versioning SQLExecDirect: UPDATE &quot;dbo&quot;.&quot;authors&quot; SET &quot;au_fname&quot;=? WHERE &quot;au_id&quot; = ? AND &quot;au_lname&quot; = ? AND &quot;au_fname&quot; = ? AND &quot;phone&quot; = ? AND &quot;address&quot; = ? AND &quot;city&quot; = ? AND &quot;state&quot; = ? AND &quot;zip&quot; = ? AND &quot;contract&quot; = ? Timestamps SQLExecDirect: UPDATE &quot;dbo&quot;.&quot;authors&quot; SET &quot;au_fname&quot;=? WHERE &quot;au_id&quot; = ? AND &quot;ts&quot; = ? Timestamps improve efficiency and remove potential problems with rounding errors in numerical data
  33. 33. LINQ <ul><li>Visual Studio 2005 bound controls don’t support timestamp checking </li></ul><ul><li>Walkthrough: Using a Timestamp with the LinqDataSource Control to Check Data Integrity </li></ul><ul><ul><li> </li></ul></ul><ul><li>Walkthrough: Selecting and Filtering a Subset of Data with the LinqDataSource and GridView Controls </li></ul><ul><ul><li> </li></ul></ul>
  34. 34. Visual Studio, write-back failure with null values <ul><li>If @original_CompanyName is null and new value is null then the write-back will fail when NULL=NULL (UNKNOWN) </li></ul><ul><li>For further information see </li></ul>UpdateCommand = &quot;UPDATE [Customers] SET [CompanyName] = @CompanyName…… WHERE [CustomerID] = @original_CustomerID AND [CompanyName] = @original_CompanyName”
  35. 35. Example Visual Studio Update handling Null Values UpdateCommand = &quot;UPDATE [Customers] SET [CompanyName] = @CompanyName WHERE [CustomerID] = @original_CustomerID COALESCE([CompanyName],'') = COALESCE(@original_ CompanyName,'')” For numerics use COALESCE([fieldname],0) For dates use COALESCE([fieldname],’ 1st January 1900’ ) Or ([CompanyName] = @original_CompanyName ) OR ([CompanyName] IS NULL and @original_CompanyName IS NULL) Or use SET ANSI_NULLS OFF
  36. 36. tsequal function <ul><li>Time stamps can not be directly compared by a program, although SQL Server has a function called tsequal which can perform a comparison in a stored procedure. </li></ul><ul><li>WHERE tsequal(@ts1,@ts2) </li></ul>
  37. 37. Summary <ul><li>We have a diverse set of data types in the different products </li></ul><ul><li>Need to test data types for product compatibility, don’t forget different versions and drivers can have an impact </li></ul><ul><li>Access and Share Point very good compatibility </li></ul><ul><li>Access and SQL Server good compatibility </li></ul><ul><li>Share Point data easily exported and linked MOSS but WSS more difficult </li></ul><ul><li>SQL Server 2008 new data types hold great promise, and it will possible work with then in Office 2007 </li></ul>
  38. 38. Wish list <ul><li>tree presentation for XML data when linking Office to SQL Server </li></ul><ul><li>Visual Studio bound controls to display bound image data </li></ul><ul><li>Visual Studio bound controls to support timestamps </li></ul>
  39. 39. ASC Associates <ul><li>Software consultancy specialising in Access, SQL Server and .net applications </li></ul><ul><li>Migration Upsizing SQL Tool </li></ul><ul><ul><li>MUST </li></ul></ul><ul><ul><ul><li>upsizes Access databases to SQL Server 2000/2005/Express </li></ul></ul></ul><ul><ul><li>MUST+SQL </li></ul></ul><ul><ul><ul><li>converts Access queries to views and stored procedures in SQL Server 2000/2005/Express </li></ul></ul></ul><ul><ul><li>MUST+Web </li></ul></ul><ul><ul><ul><li>converts Access forms to web forms in Visual Studio projects in SQL Server 2005/Express </li></ul></ul></ul><ul><li> </li></ul><ul><li>[email_address] </li></ul>