Migrate Microsoft Access to SQL Server


Published on

Describes with notes Microsoft Migration Tools and manual steps required to migrate a Microsoft Application to an Access Data Project (ADP) with a SQL Server back-end

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • A presentation at TechEd2006 Sydney in August 2006 by Adelaide Dot Net User Group member Steve Koop on Migrating, Converting and Upsizing to SQL Server from Microsoft Access. Notes have been added to further illustrate and provide reference links to the points outlined on the slides. This has been done in preference to voice-over.. The presentation provides details the many steps required to successfully migrate the Microsoft Access Application to SQL Server Result of Migration is Transparent to Users Users still use the Microsoft Access Application which to all appearances remains unchanged except for improvements (or detriments) in performance.
  • Migrate Microsoft Access to SQL Server

    1. 2. Migrating, Converting and Upsizing to SQL Server from Microsoft Access Name – Stephen Koop Title - Principal Technologist ConvertU2
    2. 3. Agenda <ul><li>SSMA and Upsizing Wizard Functionality Comparison </li></ul><ul><li>ADP vs Linked Table Solution </li></ul><ul><li>Step by Step – Issues and Solutions </li></ul><ul><li>Methodology and Recommendations </li></ul><ul><li>Q & A </li></ul>
    3. 4. SSMA for Access <ul><li>Converts “Simple” SELECT queries only </li></ul><ul><li>Does not support ADP solutions…when ? </li></ul><ul><li>Comprehensive Data/Schema Analysis </li></ul><ul><li>Reports on issues to address before upsizing </li></ul><ul><li>Multi Database upsizing </li></ul><ul><li>Reports on issues to address post upsizing </li></ul><ul><li>Several bugs in Wizard fixed – which ones ? </li></ul><ul><li>Restricted to SQL Server 2005 and .NET 2.0 </li></ul>
    4. 5. Access 2003 Upsizing Wizard <ul><li>Supports both ADP and Linked Table Solution </li></ul><ul><li>No pre analysis reporting </li></ul><ul><li>Comprehensive Documentation from Microsoft and Third Parties </li></ul><ul><li>ADP Solution creates framework only – no syntax or code fixes in Forms, Reports and Modules </li></ul>
    5. 6. Access Data Project Solution <ul><li>True Client Server </li></ul><ul><li>End User Transparency </li></ul><ul><li>Same Complexity, Different Rules </li></ul><ul><li>Most significant performance boost </li></ul><ul><li>Gateway to Web Enabled Solutions </li></ul><ul><li>Leverages SQL Server the most </li></ul>
    6. 7. Linked Table Solution <ul><li>Not a Client Server Environment </li></ul><ul><li>Slower Performance (sometimes drastically) </li></ul><ul><li>Much Less Versatility </li></ul><ul><li>Design changes may be required to increase performance </li></ul><ul><li>Interface changes require end user retraining </li></ul><ul><li>Not for complex Access Databases </li></ul><ul><li>Less work, but more compromise </li></ul><ul><li>Access 2007 ? </li></ul>
    7. 8. SQL 2000? SQL 2005? Wizard ADP? Linked Tables? SSMA Code Modules, Forms, Reports Queries Wizard ADP? Linked Tables? Code Modules, Forms, Reports Queries Decisions, Decisions…
    8. 9. Complexity vs Time <ul><li>Data and Schema is typically 10% of ADP project </li></ul><ul><li>Queries, Forms, Reports and Modules = 90% </li></ul><ul><li>100 Objects or Less – Not complex </li></ul><ul><li>200 Objects – Complex </li></ul><ul><li>500 Objects – Very Complex </li></ul><ul><li>1000 Objects – Extremely Complex </li></ul><ul><li>Reduce by 50%+ with knowledge and strategy </li></ul><ul><li>Use third party toolsets </li></ul>
    9. 10. Step by Step – Issues and Solutions <ul><li>Access Data Project Conversion Issues </li></ul><ul><li>Encompasses Linked Table Solution </li></ul><ul><li>Undocumented Issues straight from the field </li></ul><ul><li>Expansion on Current Documentation </li></ul><ul><li>Design Changes to make it all work </li></ul><ul><li>Code Samples </li></ul><ul><li>Wiser and Smarter to the Challenge </li></ul><ul><li>Let’s get into it </li></ul>
    10. 11. Issue - SQL Server does not know who you are <ul><li>But Access did !! </li></ul><ul><li>@@SPID to the rescue </li></ul><ul><li>ADO and Form SPIDS are different </li></ul><ul><ul><li>Create Table with SPID and Access UserID columns </li></ul></ul><ul><ul><li>Initialise at Logon </li></ul></ul><ul><ul><li>Delete previous Login Rows for SPID </li></ul></ul><ul><ul><li>SELECT COL1 FROM TABLE WHERE SPID = @@SPID </li></ul></ul>
    11. 12. Issue - Reserved Words <ul><li>Table Names, Column Names, Alias references </li></ul><ul><li>Wizard tolerates some, not others when creating tables and converting queries </li></ul><ul><li>SQL Server tolerates some, not others </li></ul><ul><li>Fixed in SSMA for CREATE TABLE (Reserved Word) Tablename!!! </li></ul><ul><ul><li>Encapsulate references in SQL Statements with [ ] where possible </li></ul></ul><ul><ul><li>Otherwise Rename and Identify cascading effect </li></ul></ul>
    12. 13. Issue - Table Relationship Rules <ul><li>Fields must be same length </li></ul><ul><li>Wizard demands same field name </li></ul><ul><li>Part of SSMA Reporting ! </li></ul><ul><ul><li>Remove Relationship </li></ul></ul><ul><ul><li>Remove Index </li></ul></ul><ul><ul><li>Change Field Size to Highest Length </li></ul></ul><ul><ul><li>Reinstate Index </li></ul></ul><ul><ul><li>Reinstate Relationship </li></ul></ul>
    13. 14. Issue - Date Fields can be Corrupt or Invalid in Access <ul><li>Wizard will not upsize tables with column dates less than 01/01/1900 or greater than 31/12/2078 </li></ul><ul><li>Fixed in SSMA !! For dates out of range </li></ul><ul><ul><li>Compounded if no Format Property </li></ul></ul><ul><ul><li>Remove Rows with Dates out of Range </li></ul></ul><ul><ul><li>Or change to 31/12/2078, upsize and review later </li></ul></ul>
    14. 15. Issue - Tables without Unique Index will not Upsize <ul><li>Simple Solution </li></ul><ul><li>Part of SSMA Reporting !! </li></ul><ul><ul><li>Create AutoNumber Primary Key </li></ul></ul><ul><ul><li>Or add Primary or Unique Index to existing field if design is not compromised by doing so </li></ul></ul>
    15. 16. Issue - Memo Fields get Converted to Ntext <ul><li>Restrictions apply in SQL Statements </li></ul><ul><li>Cannot Sort, Compare, or use as part of DISTINCT </li></ul><ul><ul><li>Use CONVERT </li></ul></ul><ul><ul><li>Eg SELECT DISTINCT Convert(varchar,[fieldname]) as [fieldname] FROM… </li></ul></ul>
    16. 17. Issue - AutoNumbers generate at different update status <ul><li>Post Update with SQL Server </li></ul><ul><li>Pre Update with Microsoft Access </li></ul><ul><ul><li>Use SELECT @@IDENTITY as … </li></ul></ul>
    17. 18. Issue - Random AutoNumbers on Primary Key <ul><li>Wizard Generates Trigger and zero Default Value Constraint </li></ul><ul><li>Primary Key Violation </li></ul><ul><li>Not a common issue </li></ul><ul><ul><li>Delete the trigger </li></ul></ul><ul><ul><li>Remove 0 Default Value </li></ul></ul><ul><ul><li>Create Identity of Increment 1 and Seed 1 </li></ul></ul>
    18. 19. Issue -Parameter Queries will Not Upsize <ul><li>Requires Conversion to Parametised Stored Proc or Function </li></ul><ul><ul><li>Careful – Views will not recognize stored procs </li></ul></ul>
    19. 20. Issue - Numeric Alias <ul><li>Requires Encapsulation with [ ] </li></ul><ul><ul><li>Eg SELECT REF AS [10] FROM… </li></ul></ul>
    20. 21. Issue - Concatenation Character <ul><li>Will only upsize from & to + in simple SQL Statements </li></ul><ul><li>Concatenation of Numeric Fields effect spacing </li></ul><ul><ul><li>Use LTRIM(CONVERT(varchar(255),fieldname)) </li></ul></ul>
    21. 22. Issue - Double Quote Literal String <ul><li>Will only upsize from double quote to single in simple SQL Statements </li></ul><ul><li>Difficult to identify in VBA Code </li></ul><ul><ul><li>Replace line of code with double quotes to single and force compile error </li></ul></ul><ul><ul><li>Manually fix until compilation is achieved </li></ul></ul>
    22. 23. Issue - ORDER BY <ul><li>Requires Reference in Select Clause </li></ul><ul><ul><li>SELECT COL1 FROM TABLE ORDER BY COL2 </li></ul></ul><ul><ul><li>Converts to </li></ul></ul><ul><ul><li>SELECT COL1,COL2 FROM TABLE ORDER BY COL2 </li></ul></ul><ul><ul><li>Or refer to subquery containing ORDER BY to hide COL2 </li></ul></ul>
    23. 24. Issue - UPDATE Queries <ul><li>Will not upsize </li></ul><ul><li>JOINS must occur after FROM Clause </li></ul><ul><ul><li>UPDATE TABLE INNER JOIN…SET… </li></ul></ul><ul><ul><li>Converts to </li></ul></ul><ul><ul><li>UPDATE TABLE FROM TABLE INNER JOIN…SET.. </li></ul></ul>
    24. 25. Issue – Views with ORDER BY <ul><li>Will not upsize </li></ul><ul><li>Requires (Superfluous) TOP 100 PERCENT </li></ul><ul><li>STILL an ISSUE with SQL Server 2005 </li></ul><ul><ul><li>SELECT TOP 100 PERCENT * FROM… ORDER BY </li></ul></ul>
    25. 26. Issue – UPDATE View instead of Table <ul><li>Will not function for Views with TOP OR ORDER BY </li></ul><ul><ul><li>Create a base view without TOP and ORDER BY </li></ul></ul><ul><ul><li>UPDATE the base view </li></ul></ul><ul><ul><li>Create new view with TOP and ORDER BY referring to base view </li></ul></ul>
    26. 27. Issue – Partial Inserts with Unique Constraints <ul><li>Not Supported in SQL Server </li></ul><ul><li>Transaction will not occur, ie all or nothing </li></ul><ul><ul><li>INSERT INTO TABLE1 (COL1) FROM SELECT COL2 FROM TABLE2 </li></ul></ul><ul><ul><li>Append the following condition </li></ul></ul><ul><ul><li>WHERE NOT EXISTS(SELECT COL1 FROM TABLE1 WHERE COL1 = COL2) </li></ul></ul>
    27. 28. Issue - WILDCARDS <ul><li>Will only upsize for Simple SQL Statements </li></ul><ul><ul><li>Requires Ansi89 conversion to Ansi92 </li></ul></ul><ul><ul><li>Eg LIKE ‘*SMITH’ converts to LIKE ‘%SMITH’ </li></ul></ul><ul><ul><li>Eg LIKE ‘SMITH’ converts to LIKE ‘%SMITH%’ </li></ul></ul>
    28. 29. Issue – Criteria referring to Date Literals <ul><li>Will not upsize </li></ul><ul><li># Symbol requires conversion to single quote </li></ul><ul><li>Month and Day Sequence can conflict with Locale Settings of SQL Server </li></ul><ul><li>CLNG(datefield) in VBA requires formatting </li></ul><ul><ul><li>Use mmm syntax in SQL Statements - </li></ul></ul><ul><ul><li>Use Format(xxx,’.. MMM..’) in VBA Code refs </li></ul></ul>
    29. 30. Issue - Boolean References <ul><li>Will only upsize for simple SQL Statements </li></ul><ul><li>TRUE, FALSE, YES, NO are not recognized </li></ul><ul><li>= -1 for True will compile but will malfunction </li></ul><ul><ul><li>True or -1 converts to =1 or <> 0 </li></ul></ul><ul><ul><li>False converts to =0 or <> 1 </li></ul></ul><ul><ul><li>ADO converts bit fields back to True/False in Recordsets </li></ul></ul>
    30. 31. Issue - Access Functions in SQL Statements and Object properties <ul><li>Many are not supported – UDF required </li></ul><ul><li>Others Require syntax change </li></ul><ul><li>In Particular… </li></ul><ul><ul><li>VAL </li></ul></ul><ul><ul><li>FORMAT </li></ul></ul><ul><ul><li>TRANSFORM </li></ul></ul><ul><ul><li>FIRST & LAST </li></ul></ul>
    31. 32. Issue – VAL Function <ul><li>Requires a UDF </li></ul><ul><ul><li>CREATE FUNCTION VAL(@P1 VARCHAR) AS BEGIN RETURN CONVERT(INT,LEFT(@P1,PATINDEX(('%[^0-9]%',@P1+' ')-1)) END </li></ul></ul>
    32. 33. Issue – FIRST ,LAST and DLOOKUP Functions <ul><li>AutoNumber or DateTimeStamp dependancy </li></ul><ul><li>Solution Can effect performance </li></ul><ul><ul><li>SELECT LAST(COL1) FROM TABLENAME </li></ul></ul><ul><ul><li>Converts to.. </li></ul></ul><ul><ul><li>SELECT COL1 FROM TABLENAME WHERE AUTOID = (SELECT MAX(AUTOID) FROM TABLENAME) </li></ul></ul><ul><ul><li>Similar concept for DLOOKUP using COUNT instead of MIN/MAX </li></ul></ul>
    33. 34. Issue – Properties that can use Access Functions <ul><li>DefaultValue </li></ul><ul><li>Rowsource when type is Value List </li></ul><ul><li>ControlSource Property </li></ul><ul><li>VBA Code </li></ul><ul><ul><li>Case by case assessment </li></ul></ul>
    34. 35. Issue - Alias References <ul><li>Cannot be referred to elsewhere in SQL Statement </li></ul><ul><li>Requires reference to alias definition, not alias </li></ul><ul><ul><li>SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 THEN A ELSE B END </li></ul></ul><ul><ul><li>Converts to </li></ul></ul><ul><ul><li>SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 THEN 5 ELSE 10 END </li></ul></ul>
    35. 36. Issue – Form and Report Controls <ul><li>Forms!FormName!ControlName is not recognized by SQL Server </li></ul><ul><li>Requires conversion to parametised stored proc or function </li></ul><ul><ul><li>Pass Forms!Formname!ControlName as parameter </li></ul></ul>
    36. 37. Issue – RecordSource refers to Parameter Query <ul><li>Use InputParameters Property </li></ul><ul><li>Must be Stored Proc, not a User Defined Function </li></ul><ul><ul><li>Eg InputParameters = Forms!FormName!ControlName </li></ul></ul>
    37. 38. Issue – Rowsource refers to Parameter Query <ul><li>Must be Stored Proc, not a User Defined Function </li></ul><ul><li>But where do the parameters go ? </li></ul><ul><ul><li>Use VBA Enter Event Procedure Override </li></ul></ul><ul><ul><li>ControlName.Rowsource = “Exec ProcName “ & Forms!FormName!ControlName </li></ul></ul>
    38. 39. Issue – VBA User Defined Functions <ul><li>Not recognized by SQL Server </li></ul><ul><li>Requires VBA UDF conversion to SQL Server UDF </li></ul><ul><ul><li>Generate SQL Server UDF Template(s) First </li></ul></ul><ul><ul><li>Upsize Queries </li></ul></ul><ul><ul><li>Develop Functional SQL Server UDF </li></ul></ul>
    39. 40. Issue – Encapsulated references in WHERE clause that are not an Alias and not a Column <ul><li>These are undefined input parameter fields </li></ul><ul><ul><li>Convert to Parametised Stored Proc or Function </li></ul></ul><ul><ul><li>Don’t forget if RecordSource or Rowsource </li></ul></ul>
    40. 41. Issue - The DAO Programming Library <ul><li>Is not Supported for Access Data Projects </li></ul><ul><li>DAO must be converted to ADO </li></ul><ul><ul><li>Completely Documented by Microsoft and Third Parties </li></ul></ul><ul><ul><li>StraightForward, but not a global search and replace solution </li></ul></ul><ul><ul><li>Remove DAO reference and add ADO reference </li></ul></ul><ul><ul><li>Fix until code compiles </li></ul></ul><ul><ul><li>Won’t Compile ? Won’t Run ? … </li></ul></ul>
    41. 42. Issue – RecordSet bound Forms <ul><li>ADP does not support me.fieldname </li></ul><ul><li>Compilation Error </li></ul><ul><li>Requires reference to recordset </li></ul><ul><ul><li>Me.Fieldname </li></ul></ul><ul><ul><li>Converts to… </li></ul></ul><ul><ul><li>Me.RecordSet(“FieldName”).Value </li></ul></ul>
    42. 43. Issue – RecordSet Find <ul><li>FIND Property of RecordSet cannot refer to AND or OR </li></ul><ul><li>Requires MOVEFIRST if converted from DAO FindFirst </li></ul><ul><ul><li>Use the Filter property for multiple criteria Finds </li></ul></ul><ul><ul><li>Write a VBA Function to encompass both scenarios </li></ul></ul><ul><ul><li>Sample Code .. </li></ul></ul>
    43. 44. Issue - DOCMD <ul><li>Acquery constant no longer applies </li></ul><ul><li>Requires Conversion to SQL Server Equivalent </li></ul><ul><li>OpenQuery, SelectObject, DeleteObject, ApplyFilter </li></ul><ul><ul><li>eg OpenQuery converts to OpenServerView </li></ul></ul><ul><ul><li>Acquery converts to acStoredProcedure,acView or acFunction </li></ul></ul><ul><ul><li>Solution -Use Type and Name columns of SysObjects </li></ul></ul><ul><ul><li>ApplyFilter requires conversion to ANSI92 </li></ul></ul>
    44. 45. Methodology and Recommendations <ul><li>Don’t jump in cold when your application is complex </li></ul><ul><ul><li>Know the traps and pitfalls </li></ul></ul><ul><ul><li>Learn the tips and tricks </li></ul></ul><ul><ul><li>Scan Scan Scan – write (DAO) scripts to find the issues </li></ul></ul><ul><ul><li>Identify and Track the cascading effect </li></ul></ul><ul><ul><li>Management , Knowledge and strategy will ensure successful migration </li></ul></ul>
    45. 46. IT’S ALL ON OUR WEB SITE <ul><li>WWW.CONVERTU2.COM </li></ul><ul><li>Can’t Solve an Upsizing, Migration, or Conversion Issue ? </li></ul><ul><li>ASK US </li></ul>
    46. 47. © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.