Microsoft (SQL Server)
-
Upload
vinayak-hegde -
Category
Education
-
view
1.969 -
download
0
Transcript of Microsoft (SQL Server)
Migrating, Converting and Migrating, Converting and Upsizing to SQL Server from Upsizing to SQL Server from
Microsoft AccessMicrosoft Access
AgendaAgenda
SSMA and Upsizing Wizard Functionality SSMA and Upsizing Wizard Functionality ComparisonComparisonADP vs Linked Table SolutionADP vs Linked Table SolutionStep by Step – Issues and SolutionsStep by Step – Issues and SolutionsMethodology and RecommendationsMethodology and RecommendationsQ & AQ & A
SSMA for AccessSSMA for Access
Converts “Simple” SELECT queries onlyConverts “Simple” SELECT queries onlyDoes not support ADP solutions…when ?Does not support ADP solutions…when ?Comprehensive Data/Schema AnalysisComprehensive Data/Schema AnalysisReports on issues to address before Reports on issues to address before upsizingupsizingMulti Database upsizingMulti Database upsizingReports on issues to address post upsizingReports on issues to address post upsizingSeveral 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 SolutionSolutionNo pre analysis reportingNo pre analysis reportingComprehensive Documentation from Comprehensive Documentation from Microsoft and Third PartiesMicrosoft and Third PartiesADP 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 ServerEnd User Transparency End User Transparency Same Complexity, Different RulesSame Complexity, Different RulesMost significant performance boostMost significant performance boostGateway to Web Enabled SolutionsGateway to Web Enabled SolutionsLeverages SQL Server the mostLeverages SQL Server the most
Linked Table SolutionLinked Table Solution
Not a Client Server EnvironmentNot a Client Server EnvironmentSlower Performance (sometimes Slower Performance (sometimes drastically) drastically) Much Less VersatilityMuch Less VersatilityDesign changes may be required to Design changes may be required to increase performanceincrease performanceInterface changes require end user Interface changes require end user retrainingretrainingNot for complex Access DatabasesNot for complex Access DatabasesLess work, but more compromiseLess work, but more compromiseAccess 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 projectprojectQueries, Forms, Reports and Modules = Queries, Forms, Reports and Modules = 90% 90% 100 Objects or Less – Not complex100 Objects or Less – Not complex200 Objects – Complex200 Objects – Complex500 Objects – Very Complex500 Objects – Very Complex1000 Objects – Extremely Complex1000 Objects – Extremely ComplexReduce by 50%+ with knowledge and Reduce by 50%+ with knowledge and strategystrategyUse 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 IssuesEncompasses Linked Table SolutionEncompasses Linked Table SolutionUndocumented Issues straight from the Undocumented Issues straight from the fieldfieldExpansion on Current DocumentationExpansion on Current DocumentationDesign Changes to make it all workDesign Changes to make it all workCode SamplesCode SamplesWiser and Smarter to the ChallengeWiser and Smarter to the ChallengeLet’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 rescueADO and Form SPIDS are differentADO and Form SPIDS are different
Create Table with SPID and Access UserID Create Table with SPID and Access UserID columnscolumnsInitialise at LogonInitialise at LogonDelete previous Login Rows for SPIDDelete previous Login Rows for SPIDSELECT 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 referencesreferencesWizard tolerates some, not others when Wizard tolerates some, not others when creating tables and converting queriescreating tables and converting queriesSQL Server tolerates some, not othersSQL Server tolerates some, not othersFixed 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 possibleOtherwise 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 lengthWizard demands same field nameWizard demands same field namePart of SSMA Reporting !Part of SSMA Reporting !
Remove RelationshipRemove RelationshipRemove IndexRemove IndexChange Field Size to Highest LengthChange Field Size to Highest LengthReinstate IndexReinstate IndexReinstate 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/2078Fixed in SSMA !! For dates out of rangeFixed in SSMA !! For dates out of range
Compounded if no Format PropertyCompounded if no Format PropertyRemove Rows with Dates out of RangeRemove Rows with Dates out of RangeOr 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 SolutionPart of SSMA Reporting !!Part of SSMA Reporting !!
Create AutoNumber Primary KeyCreate AutoNumber Primary KeyOr 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 StatementsCannot Sort, Compare, or use as part of Cannot Sort, Compare, or use as part of DISTINCTDISTINCT
Use CONVERTUse CONVERTEg 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 ServerPre 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 ConstraintPrimary Key ViolationPrimary Key ViolationNot a common issueNot a common issue
Delete the triggerDelete the triggerRemove 0 Default ValueRemove 0 Default ValueCreate 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 StatementsStatementsConcatenation 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 StatementsDifficult 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 errorManually 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 COL2Converts toConverts toSELECT COL1,COL2 FROM TABLE ORDER BY SELECT COL1,COL2 FROM TABLE ORDER BY COL2COL2Or 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 upsizeJOINS must occur after FROM ClauseJOINS must occur after FROM Clause
UPDATE TABLE INNER JOIN…SET…UPDATE TABLE INNER JOIN…SET…Converts toConverts toUPDATE 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 upsizeRequires (Superfluous) TOP 100 PERCENTRequires (Superfluous) TOP 100 PERCENTSTILL 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 BYUPDATE the base viewUPDATE the base viewCreate 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 ServerTransaction 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 conditionWHERE 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 Ansi92Eg 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 quotequoteMonth and Day Sequence can conflict with Month and Day Sequence can conflict with Locale Settings of SQL ServerLocale Settings of SQL ServerCLNG(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 StatementsTRUE, 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 <> 0False converts to =0 or <> 1False converts to =0 or <> 1ADO 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
propertiespropertiesMany are not supported – UDF requiredMany are not supported – UDF requiredOthers Require syntax changeOthers Require syntax changeIn Particular…In Particular…
VALVALFORMATFORMATTRANSFORMTRANSFORMFIRST & 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 dependancydependancySolution Can effect performanceSolution Can effect performance
SELECT LAST(COL1) FROM TABLENAMESELECT LAST(COL1) FROM TABLENAMEConverts 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
DefaultValueDefaultValueRowsource when type is Value ListRowsource when type is Value ListControlSource PropertyControlSource PropertyVBA 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 StatementStatementRequires 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 ENDConverts toConverts toSELECT 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 ServerRequires 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 PropertyMust 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 FunctionFunctionBut where do the parameters go ?But where do the parameters go ?
Use VBA Enter Event Procedure OverrideUse VBA Enter Event Procedure OverrideControlName.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 ServerRequires 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) FirstUpsize QueriesUpsize QueriesDevelop 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 ColumnThese are undefined input parameter fieldsThese are undefined input parameter fields
Convert to Parametised Stored Proc or FunctionConvert to Parametised Stored Proc or FunctionDon’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 ProjectsDAO must be converted to ADODAO must be converted to ADO
Completely Documented by Microsoft and Third Completely Documented by Microsoft and Third PartiesPartiesStraightForward, but not a global search and StraightForward, but not a global search and replace solutionreplace solutionRemove DAO reference and add ADO referenceRemove DAO reference and add ADO referenceFix until code compilesFix until code compilesWon’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.fieldnameCompilation ErrorCompilation ErrorRequires reference to recordsetRequires reference to recordset
Me.FieldnameMe.FieldnameConverts 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 ORRequires 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 FindsWrite a VBA Function to encompass both Write a VBA Function to encompass both scenariosscenariosSample Code ..Sample Code ..
Issue - DOCMDIssue - DOCMD
Acquery constant no longer appliesAcquery constant no longer appliesRequires Conversion to SQL Server Requires Conversion to SQL Server EquivalentEquivalentOpenQuery, SelectObject, DeleteObject, OpenQuery, SelectObject, DeleteObject, ApplyFilterApplyFilter
eg OpenQuery converts to OpenServerVieweg OpenQuery converts to OpenServerViewAcquery converts to acStoredProcedure,acView Acquery converts to acStoredProcedure,acView or acFunctionor acFunctionSolution -Use Type and Name columns of Solution -Use Type and Name columns of SysObjectsSysObjectsApplyFilter 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 pitfallsLearn the tips and tricksLearn the tips and tricksScan Scan Scan – write (DAO) scripts to find the Scan Scan Scan – write (DAO) scripts to find the issuesissuesIdentify and Track the cascading effectIdentify and Track the cascading effectManagement , Knowledge and strategy will Management , Knowledge and strategy will ensure successful migrationensure successful migration
Information collected and Information collected and Slides Prepared bySlides Prepared by
Vinayak NandikalVinayak Nandikal