Databases compare

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi

Is it possible to compare if 2 databases have the same
structure(same tables, and same name of fields)


Thanks
 
Hi Chris,

My name is Dennis Schmidt. Thank you for using the Microsoft Newsgroups.

I am not aware of any tool that does this. You could use Tools | Analyze |
Documentor to print out hard copies of the tables\fields and much other
information which you could then compare.

I hope this helps! If you have additional questions on this topic, please
reply to this posting.

Need quick answers to questions like these? The Microsoft Knowledge Base
provides a wealth of information that you can use to troubleshoot a problem
or answer a question! It's located at
http://support.microsoft.com/support/c.asp?M=F>.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

Regards,
Dennis Schmidt
Microsoft Support
 
Hi,

I wrote this function to do what you are talking about... you will need
to clean it up a bit


Code:
--------------------

Sub check2()
On Error GoTo errcheck2
Dim Apples As Database, Bananas As Database, Tee As TableDef, Ess As TableDef
Dim foundIt As Boolean, Eff As Field, Gee As Field
Dim Pee As Property, Kyu As Property
Set Apples = OpenDatabase("C:\currentcopies\testcalchistory.mdb")
Set Bananas = OpenDatabase("C:\currentcopies\calchistory.mdb")

For Each Tee In Apples.TableDefs
foundIt = False
For Each Ess In Bananas.TableDefs
If Ess.Name = Tee.Name Then
foundIt = True
Exit For
End If
Next
If foundIt Then
For Each Eff In Ess.Fields
foundIt = False
For Each Gee In Tee.Fields
If Eff.Name = Gee.Name Then
foundIt = True
Exit For
End If
Next
If foundIt Then
If Eff.Size <> Gee.Size Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".Size = " & Eff.Size & " (was = " & Gee.Size & ")"
If Eff.Type <> Gee.Type Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".Type= " & Eff.Type & " (was = " & Gee.Type & ")"
If Eff.AllowZeroLength <> Gee.AllowZeroLength Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".AllowZeroLength = " & Eff.AllowZeroLength & " (was = " & Gee.AllowZeroLength & ")"
If Eff.DefaultValue <> Gee.DefaultValue Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".DefaultValue = " & Eff.DefaultValue & " (was = " & Gee.DefaultValue & ")"
Else
Debug.Print "Lost Field " & Tee.Name & "." & Eff.Name
End If
Next
Else
Debug.Print "Lost Table " & Tee.Name
End If
Next

For Each Tee In Bananas.TableDefs
foundIt = False
For Each Ess In Apples.TableDefs
If Ess.Name = Tee.Name Then
foundIt = True
Exit For
End If
Next
If foundIt Then
For Each Eff In Ess.Fields
foundIt = False
For Each Gee In Tee.Fields
If Eff.Name = Gee.Name Then
foundIt = True
Exit For
End If
Next
If foundIt Then
If Eff.Size <> Gee.Size Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".Size = " & Eff.Size & " (was = " & Gee.Size & ")"
If Eff.Type <> Gee.Type Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".Type= " & Eff.Type & " (was = " & Gee.Type & ")"
If Eff.AllowZeroLength <> Gee.AllowZeroLength Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".AllowZeroLength = " & Eff.AllowZeroLength & " (was = " & Gee.AllowZeroLength & ")"
If Eff.DefaultValue <> Gee.DefaultValue Then Debug.Print "Field Changed: " & Tee.Name & "." & Eff.Name & ".DefaultValue = " & Eff.DefaultValue & " (was = " & Gee.DefaultValue & ")"
Else
Debug.Print "Lost Field " & Tee.Name & "." & Eff.Name
End If
Next
Else
Debug.Print "Lost Table " & Tee.Name
End If
Next

Set Ess = Nothing
Set Tee = Nothing
Set Apples = Nothing
Set Bananas = Nothing
Set Eff = Nothing
Set Gee = Nothing
Exit Sub
errcheck2:
LogErr "Module1", err.Number, err.Description, "check2"
End Sub


--------------------


hope this helps,

aaron
 
Back
Top