Migrate Microsoft Access to SQL Server
-
Upload
adnug -
Category
Technology
-
view
27.107 -
download
2
description
Transcript of Migrate Microsoft Access to SQL Server
Migrating, Converting Migrating, Converting and Upsizing to SQL and Upsizing to SQL Server from Microsoft Server from Microsoft AccessAccess
Migrating, Converting Migrating, Converting and Upsizing to SQL and Upsizing to SQL Server from Microsoft Server from Microsoft AccessAccess
Name – Stephen KoopName – Stephen KoopTitle - Principal TechnologistTitle - Principal TechnologistConvertU2ConvertU2
AgendaAgenda
SSMA and Upsizing Wizard Functionality SSMA and Upsizing Wizard Functionality ComparisonComparison
ADP vs Linked Table SolutionADP vs Linked Table Solution
Step by Step – Issues and SolutionsStep by Step – Issues and Solutions
Methodology and RecommendationsMethodology and Recommendations
Q & AQ & A
SSMA for AccessSSMA for Access
Converts “Simple” SELECT queries onlyConverts “Simple” SELECT queries only
Does not support ADP solutions…when ?Does not support ADP solutions…when ?
Comprehensive Data/Schema AnalysisComprehensive Data/Schema Analysis
Reports on issues to address before Reports on issues to address before upsizingupsizing
Multi Database upsizingMulti Database upsizing
Reports on issues to address post upsizingReports on issues to address post upsizing
Several bugs in Wizard fixed – which ones ?Several bugs in Wizard fixed – which ones ?
Restricted to SQL Server 2005 and .NET 2.0Restricted to SQL Server 2005 and .NET 2.0
Access 2003 Upsizing WizardAccess 2003 Upsizing Wizard
Supports both ADP and Linked Table Supports both ADP and Linked Table SolutionSolution
No pre analysis reportingNo pre analysis reporting
Comprehensive Documentation from Comprehensive Documentation from Microsoft and Third PartiesMicrosoft and Third Parties
ADP Solution creates framework only – no ADP Solution creates framework only – no syntax or code fixes in Forms, Reports and syntax or code fixes in Forms, Reports and ModulesModules
Access Data Project SolutionAccess Data Project Solution
True Client ServerTrue Client Server
End User Transparency End User Transparency
Same Complexity, Different RulesSame Complexity, Different Rules
Most significant performance boostMost significant performance boost
Gateway to Web Enabled SolutionsGateway to Web Enabled Solutions
Leverages SQL Server the mostLeverages SQL Server the most
Linked Table SolutionLinked Table Solution
Not a Client Server EnvironmentNot a Client Server Environment
Slower Performance (sometimes Slower Performance (sometimes drastically) drastically)
Much Less VersatilityMuch Less Versatility
Design changes may be required to Design changes may be required to increase performanceincrease performance
Interface changes require end user Interface changes require end user retrainingretraining
Not for complex Access DatabasesNot for complex Access Databases
Less work, but more compromiseLess work, but more compromise
Access 2007 ?Access 2007 ?
SQL 2000? SQL 2005?
WizardADP? Linked Tables?
SSMA
Code Modules, Forms, Reports
Queries
WizardADP?Linked Tables?
Code Modules, Forms, Reports
Queries
Decisions, Decisions…Decisions, Decisions…
Complexity vs TimeComplexity vs Time
Data and Schema is typically 10% of ADP Data and Schema is typically 10% of ADP projectproject
Queries, Forms, Reports and Modules = Queries, Forms, Reports and Modules = 90% 90%
100 Objects or Less – Not complex100 Objects or Less – Not complex
200 Objects – Complex200 Objects – Complex
500 Objects – Very Complex500 Objects – Very Complex
1000 Objects – Extremely Complex1000 Objects – Extremely Complex
Reduce by 50%+ with knowledge and Reduce by 50%+ with knowledge and strategystrategy
Use third party toolsetsUse third party toolsets
Step by Step – Issues and Step by Step – Issues and SolutionsSolutions
Access Data Project Conversion IssuesAccess Data Project Conversion Issues
Encompasses Linked Table SolutionEncompasses Linked Table Solution
Undocumented Issues straight from the Undocumented Issues straight from the fieldfield
Expansion on Current DocumentationExpansion on Current Documentation
Design Changes to make it all workDesign Changes to make it all work
Code SamplesCode Samples
Wiser and Smarter to the ChallengeWiser and Smarter to the Challenge
Let’s get into itLet’s get into it
Issue - SQL Server does not Issue - SQL Server does not know who you areknow who you are
But Access did !!But Access did !!
@@SPID to the rescue@@SPID to the rescue
ADO and Form SPIDS are differentADO and Form SPIDS are different
Create Table with SPID and Access UserID Create Table with SPID and Access UserID columnscolumns
Initialise at LogonInitialise at Logon
Delete previous Login Rows for SPIDDelete previous Login Rows for SPID
SELECT COL1 FROM TABLE WHERE SPID = SELECT COL1 FROM TABLE WHERE SPID = @@SPID@@SPID
Issue - Reserved WordsIssue - Reserved Words
Table Names, Column Names, Alias Table Names, Column Names, Alias referencesreferences
Wizard tolerates some, not others when Wizard tolerates some, not others when creating tables and converting queriescreating tables and converting queries
SQL Server tolerates some, not othersSQL Server tolerates some, not others
Fixed in SSMA for CREATE TABLE (Reserved Fixed in SSMA for CREATE TABLE (Reserved Word) Tablename!!!Word) Tablename!!!
Encapsulate references in SQL Statements with Encapsulate references in SQL Statements with [ ] where possible[ ] where possible
Otherwise Rename and Identify cascading Otherwise Rename and Identify cascading effecteffect
Issue - Table Relationship RulesIssue - Table Relationship Rules
Fields must be same lengthFields must be same length
Wizard demands same field nameWizard demands same field name
Part of SSMA Reporting !Part of SSMA Reporting !
Remove RelationshipRemove Relationship
Remove IndexRemove Index
Change Field Size to Highest LengthChange Field Size to Highest Length
Reinstate IndexReinstate Index
Reinstate RelationshipReinstate Relationship
Issue - Date Fields can be Issue - Date Fields can be Corrupt or Invalid in AccessCorrupt or Invalid in Access
Wizard will not upsize tables with column Wizard will not upsize tables with column dates less than 01/01/1900 or greater dates less than 01/01/1900 or greater than 31/12/2078than 31/12/2078
Fixed in SSMA !! For dates out of rangeFixed in SSMA !! For dates out of range
Compounded if no Format PropertyCompounded if no Format Property
Remove Rows with Dates out of RangeRemove Rows with Dates out of Range
Or change to 31/12/2078, upsize and review Or change to 31/12/2078, upsize and review laterlater
Issue - Tables without Unique Issue - Tables without Unique Index will not UpsizeIndex will not Upsize
Simple SolutionSimple Solution
Part of SSMA Reporting !!Part of SSMA Reporting !!
Create AutoNumber Primary KeyCreate AutoNumber Primary Key
Or add Primary or Unique Index to existing field Or add Primary or Unique Index to existing field if design is not compromised by doing soif design is not compromised by doing so
Issue - Memo Fields get Issue - Memo Fields get Converted to NtextConverted to Ntext
Restrictions apply in SQL StatementsRestrictions apply in SQL Statements
Cannot Sort, Compare, or use as part of Cannot Sort, Compare, or use as part of DISTINCTDISTINCT
Use CONVERTUse CONVERT
Eg SELECT DISTINCT Convert(varchar,Eg SELECT DISTINCT Convert(varchar,[fieldname]) as [fieldname] FROM…[fieldname]) as [fieldname] FROM…
Issue - AutoNumbers generate Issue - AutoNumbers generate at different update statusat different update status
Post Update with SQL ServerPost Update with SQL Server
Pre Update with Microsoft AccessPre Update with Microsoft Access
Use SELECT @@IDENTITY as …Use SELECT @@IDENTITY as …
Issue - Random AutoNumbers Issue - Random AutoNumbers on Primary Keyon Primary Key
Wizard Generates Trigger and zero Default Wizard Generates Trigger and zero Default Value ConstraintValue Constraint
Primary Key ViolationPrimary Key Violation
Not a common issueNot a common issue
Delete the triggerDelete the trigger
Remove 0 Default ValueRemove 0 Default Value
Create Identity of Increment 1 and Seed 1Create Identity of Increment 1 and Seed 1
Issue -Parameter Queries will Issue -Parameter Queries will Not UpsizeNot Upsize
Requires Conversion to Parametised Stored Requires Conversion to Parametised Stored Proc or FunctionProc or Function
Careful – Views will not recognize stored procsCareful – Views will not recognize stored procs
Issue - Numeric AliasIssue - Numeric Alias
Requires Encapsulation with [ ]Requires Encapsulation with [ ]
Eg SELECT REF AS [10] FROM…Eg SELECT REF AS [10] FROM…
Issue - Concatenation CharacterIssue - Concatenation Character
Will only upsize from & to + in simple SQL Will only upsize from & to + in simple SQL StatementsStatements
Concatenation of Numeric Fields effect Concatenation of Numeric Fields effect spacingspacing
Use LTRIM(CONVERT(varchar(255),fieldname))Use LTRIM(CONVERT(varchar(255),fieldname))
Issue - Double Quote Literal Issue - Double Quote Literal StringString
Will only upsize from double quote to Will only upsize from double quote to single in simple SQL Statementssingle in simple SQL Statements
Difficult to identify in VBA CodeDifficult to identify in VBA Code
Replace line of code with double quotes to Replace line of code with double quotes to single and force compile errorsingle and force compile error
Manually fix until compilation is achievedManually fix until compilation is achieved
Issue - ORDER BYIssue - ORDER BY
Requires Reference in Select ClauseRequires Reference in Select Clause
SELECT COL1 FROM TABLE ORDER BY COL2SELECT COL1 FROM TABLE ORDER BY COL2
Converts toConverts to
SELECT COL1,COL2 FROM TABLE ORDER BY SELECT COL1,COL2 FROM TABLE ORDER BY COL2COL2
Or refer to subquery containing ORDER BY to Or refer to subquery containing ORDER BY to hide COL2hide COL2
Issue - UPDATE QueriesIssue - UPDATE Queries
Will not upsizeWill not upsize
JOINS must occur after FROM ClauseJOINS must occur after FROM Clause
UPDATE TABLE INNER JOIN…SET…UPDATE TABLE INNER JOIN…SET…
Converts toConverts to
UPDATE TABLE FROM TABLE INNER JOIN…SET..UPDATE TABLE FROM TABLE INNER JOIN…SET..
Issue – Views with ORDER BYIssue – Views with ORDER BY
Will not upsizeWill not upsize
Requires (Superfluous) TOP 100 PERCENTRequires (Superfluous) TOP 100 PERCENT
STILL an ISSUE with SQL Server 2005STILL an ISSUE with SQL Server 2005
SELECT TOP 100 PERCENT * FROM… ORDER BYSELECT TOP 100 PERCENT * FROM… ORDER BY
Issue – UPDATE View instead of Issue – UPDATE View instead of TableTable
Will not function for Views with TOP OR Will not function for Views with TOP OR ORDER BYORDER BY
Create a base view without TOP and ORDER BYCreate a base view without TOP and ORDER BY
UPDATE the base viewUPDATE the base view
Create new view with TOP and ORDER BY Create new view with TOP and ORDER BY referring to base viewreferring to base view
Issue – Partial Inserts with Issue – Partial Inserts with Unique ConstraintsUnique Constraints
Not Supported in SQL ServerNot Supported in SQL Server
Transaction will not occur, ie all or nothingTransaction will not occur, ie all or nothing
INSERT INTO TABLE1 (COL1) FROM SELECT INSERT INTO TABLE1 (COL1) FROM SELECT COL2 FROM TABLE2 COL2 FROM TABLE2
Append the following conditionAppend the following condition
WHERE NOT EXISTS(SELECT COL1 FROM WHERE NOT EXISTS(SELECT COL1 FROM TABLE1 WHERE COL1 = COL2)TABLE1 WHERE COL1 = COL2)
Issue - WILDCARDSIssue - WILDCARDS
Will only upsize for Simple SQL StatementsWill only upsize for Simple SQL Statements
Requires Ansi89 conversion to Ansi92Requires Ansi89 conversion to Ansi92
Eg LIKE ‘*SMITH’ converts to LIKE ‘%SMITH’Eg LIKE ‘*SMITH’ converts to LIKE ‘%SMITH’
Eg LIKE ‘SMITH’ converts to LIKE ‘%SMITH%’Eg LIKE ‘SMITH’ converts to LIKE ‘%SMITH%’
Issue – Criteria referring to Date Issue – Criteria referring to Date LiteralsLiterals
Will not upsizeWill not upsize
# Symbol requires conversion to single # Symbol requires conversion to single quotequote
Month and Day Sequence can conflict with Month and Day Sequence can conflict with Locale Settings of SQL ServerLocale Settings of SQL Server
CLNG(datefield) in VBA requires formattingCLNG(datefield) in VBA requires formatting
Use mmm syntax in SQL Statements - Use mmm syntax in SQL Statements -
Use Format(xxx,’.. MMM..’) in VBA Code refsUse Format(xxx,’.. MMM..’) in VBA Code refs
Issue - Boolean ReferencesIssue - Boolean References
Will only upsize for simple SQL StatementsWill only upsize for simple SQL Statements
TRUE, FALSE, YES, NO are not recognizedTRUE, FALSE, YES, NO are not recognized
= -1 for True will compile but will = -1 for True will compile but will malfunctionmalfunction
True or -1 converts to =1 or <> 0True or -1 converts to =1 or <> 0
False converts to =0 or <> 1False converts to =0 or <> 1
ADO converts bit fields back to True/False in ADO converts bit fields back to True/False in RecordsetsRecordsets
Issue - Access Functions in SQL Issue - Access Functions in SQL Statements and Object Statements and Object propertiesproperties
Many are not supported – UDF requiredMany are not supported – UDF required
Others Require syntax changeOthers Require syntax change
In Particular…In Particular…VALVAL
FORMATFORMAT
TRANSFORMTRANSFORM
FIRST & LASTFIRST & LAST
Issue – VAL FunctionIssue – VAL Function
Requires a UDFRequires a UDF
CREATE FUNCTION VAL(@P1 VARCHAR) AS CREATE FUNCTION VAL(@P1 VARCHAR) AS BEGIN RETURN BEGIN RETURN CONVERT(INT,LEFT(@P1,PATINDEX(('%[^0-CONVERT(INT,LEFT(@P1,PATINDEX(('%[^0-9]%',@P1+' ')-1)) END9]%',@P1+' ')-1)) END
Issue – FIRST ,LAST and Issue – FIRST ,LAST and DLOOKUP FunctionsDLOOKUP Functions
AutoNumber or DateTimeStamp AutoNumber or DateTimeStamp dependancydependancy
Solution Can effect performanceSolution Can effect performance
SELECT LAST(COL1) FROM TABLENAMESELECT LAST(COL1) FROM TABLENAME
Converts to..Converts to..
SELECT COL1 FROM TABLENAME WHERE SELECT COL1 FROM TABLENAME WHERE AUTOID = (SELECT MAX(AUTOID) FROM AUTOID = (SELECT MAX(AUTOID) FROM TABLENAME)TABLENAME)
Similar concept for DLOOKUP using COUNT Similar concept for DLOOKUP using COUNT instead of MIN/MAXinstead of MIN/MAX
Issue – Properties that can use Issue – Properties that can use Access FunctionsAccess Functions
DefaultValueDefaultValue
Rowsource when type is Value ListRowsource when type is Value List
ControlSource PropertyControlSource Property
VBA CodeVBA Code
Case by case assessmentCase by case assessment
Issue - Alias ReferencesIssue - Alias References
Cannot be referred to elsewhere in SQL Cannot be referred to elsewhere in SQL StatementStatement
Requires reference to alias definition, not Requires reference to alias definition, not aliasalias
SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 THEN A ELSE B ENDTHEN A ELSE B END
Converts toConverts to
SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 SELECT 5 AS A, 10 AS B, CASE WHEN C = 1 THEN 5 ELSE 10 ENDTHEN 5 ELSE 10 END
Issue – Form and Report Issue – Form and Report ControlsControls
Forms!FormName!ControlName is not Forms!FormName!ControlName is not recognized by SQL Serverrecognized by SQL Server
Requires conversion to parametised stored Requires conversion to parametised stored proc or functionproc or function
Pass Forms!Formname!ControlName as Pass Forms!Formname!ControlName as parameterparameter
Issue – RecordSource refers to Issue – RecordSource refers to Parameter QueryParameter Query
Use InputParameters PropertyUse InputParameters Property
Must be Stored Proc, not a User Defined Must be Stored Proc, not a User Defined FunctionFunction
Eg InputParameters = Forms!FormName!Eg InputParameters = Forms!FormName!ControlNameControlName
Issue – Rowsource refers to Issue – Rowsource refers to Parameter QueryParameter Query
Must be Stored Proc, not a User Defined Must be Stored Proc, not a User Defined FunctionFunction
But where do the parameters go ?But where do the parameters go ?
Use VBA Enter Event Procedure OverrideUse VBA Enter Event Procedure Override
ControlName.Rowsource = “Exec ProcName “ & ControlName.Rowsource = “Exec ProcName “ & Forms!FormName!ControlNameForms!FormName!ControlName
Issue – VBA User Defined Issue – VBA User Defined FunctionsFunctions
Not recognized by SQL ServerNot recognized by SQL Server
Requires VBA UDF conversion to SQL Requires VBA UDF conversion to SQL Server UDFServer UDF
Generate SQL Server UDF Template(s) FirstGenerate SQL Server UDF Template(s) First
Upsize QueriesUpsize Queries
Develop Functional SQL Server UDFDevelop Functional SQL Server UDF
Issue – Encapsulated references Issue – Encapsulated references in WHERE clause that are not in WHERE clause that are not an Alias and not a Columnan Alias and not a Column
These are undefined input parameter fieldsThese are undefined input parameter fields
Convert to Parametised Stored Proc or FunctionConvert to Parametised Stored Proc or Function
Don’t forget if RecordSource or RowsourceDon’t forget if RecordSource or Rowsource
Issue - The DAO Programming Issue - The DAO Programming LibraryLibrary
Is not Supported for Access Data ProjectsIs not Supported for Access Data Projects
DAO must be converted to ADODAO must be converted to ADO
Completely Documented by Microsoft and Third Completely Documented by Microsoft and Third PartiesParties
StraightForward, but not a global search and StraightForward, but not a global search and replace solutionreplace solution
Remove DAO reference and add ADO referenceRemove DAO reference and add ADO reference
Fix until code compilesFix until code compiles
Won’t Compile ? Won’t Run ? …Won’t Compile ? Won’t Run ? …
Issue – RecordSet bound FormsIssue – RecordSet bound Forms
ADP does not support me.fieldnameADP does not support me.fieldname
Compilation ErrorCompilation Error
Requires reference to recordsetRequires reference to recordset
Me.FieldnameMe.Fieldname
Converts to…Converts to…
Me.RecordSet(“FieldName”).ValueMe.RecordSet(“FieldName”).Value
Issue – RecordSet FindIssue – RecordSet Find
FIND Property of RecordSet cannot refer to FIND Property of RecordSet cannot refer to AND or ORAND or OR
Requires MOVEFIRST if converted from Requires MOVEFIRST if converted from DAO FindFirstDAO FindFirst
Use the Filter property for multiple criteria FindsUse the Filter property for multiple criteria Finds
Write a VBA Function to encompass both Write a VBA Function to encompass both scenariosscenarios
Sample Code ..Sample Code ..
Issue - DOCMDIssue - DOCMD
Acquery constant no longer appliesAcquery constant no longer applies
Requires Conversion to SQL Server Requires Conversion to SQL Server EquivalentEquivalent
OpenQuery, SelectObject, DeleteObject, OpenQuery, SelectObject, DeleteObject, ApplyFilterApplyFilter
eg OpenQuery converts to OpenServerVieweg OpenQuery converts to OpenServerView
Acquery converts to acStoredProcedure,acView Acquery converts to acStoredProcedure,acView or acFunctionor acFunction
Solution -Use Type and Name columns of Solution -Use Type and Name columns of SysObjectsSysObjects
ApplyFilter requires conversion to ANSI92ApplyFilter requires conversion to ANSI92
Methodology and Methodology and RecommendationsRecommendations
Don’t jump in cold when your application is Don’t jump in cold when your application is complexcomplex
Know the traps and pitfallsKnow the traps and pitfalls
Learn the tips and tricksLearn the tips and tricks
Scan Scan Scan – write (DAO) scripts to find the Scan Scan Scan – write (DAO) scripts to find the issuesissues
Identify and Track the cascading effectIdentify and Track the cascading effect
Management , Knowledge and strategy will Management , Knowledge and strategy will ensure successful migrationensure successful migration
IT’S ALL ON OUR WEB SITEIT’S ALL ON OUR WEB SITE
WWW.CONVERTU2.COMWWW.CONVERTU2.COM
Can’t Solve an Upsizing, Migration, or Can’t Solve an Upsizing, Migration, or Conversion Issue ?Conversion Issue ?
ASK USASK US
© 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.