我想比较两个Access数据库,并检查是否存在任何字段或类型不匹配。
我们有什么方法可以检查使用数据集还是有更快的方法来做到这一点?
感谢。
答案 0 :(得分:3)
您可以使用StarInix软件的免费数据库比较2.0(review)进行比较。
答案 1 :(得分:3)
为每个数据库执行此操作,并使用您选择的diff工具比较文本文件。
答案 2 :(得分:1)
我一直是Access Pro Table Compare。我在网上找到了它,它在比较MS Access表,查找字段和数据类型问题等方面非常有用。
答案 3 :(得分:0)
您可以像访问SQL Server数据库一样,使用ODBC驱动程序读取访问数据库中的系统表(默认情况下是隐藏的)。
答案 4 :(得分:0)
我已经创建了一个AccdbMerge实用程序,可以比较Access对象和数据。在模式比较的范围内 - 它允许比较表和查询的列表以及每个表/查询定义。
答案 5 :(得分:-1)
Option Compare Database
Private Sub Command14_Click()
Dim tablename1, tablename2, field_date As String
tablename1 = Text10.Value
tablename2 = Text13.Value
flter_date = Text16.Value
length = Len(tablename1) - Len("gahpu00d_")
field_date = Right(tablename1, length) & "_posted_dt"
'On Error GoTo Err_cmdValidateGeneralInfo_Click
Dim F As DAO.Field
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Set curDB = CurrentDb()
DoCmd.CopyObject , "Unmatched_records", acTable, tablename1
curDB.Execute "DELETE FROM Unmatched_records"
'to calculate count of filtered data in staged
strsql = "Select * from " & tablename1 & " where cdate(" & field_date & ") = """ & flter_date & """ order by " & field_date & ""
DoCmd.RunSQL "Select * into filter_data1 from " & tablename1 & " where cdate(" & field_date & ") = """ & flter_date & """"
count_data1 = DCount(field_date, "filter_data1")
Text18.Enabled = True
Text18.Value = count_data1
'to calculate count of filtered data in production
strsql1 = "Select * from " & tablename2 & " where cdate(" & field_date & ") = """ & flter_date & """ order by " & field_date & ""
DoCmd.RunSQL "Select * into filter_data2 from " & tablename2 & " where cdate(" & field_date & ") = """ & flter_date & """"
count_data2 = DCount(field_date, "filter_data2")
Text20.Enabled = True
Text20.Value = count_data2
If count_data1 <> count_data2 Then
If count_data1 > count_data2 Then
MsgBox "The number of records in the table didnt match." & tablename1 & " has more records than " & tablename2
Exit Sub
Else
MsgBox "The number of records in the table didnt match." & tablename2 & " has more records than " & tablename1
Exit Sub
End If
End If
Set rs = curDB.OpenRecordset(strsql)
Set rs1 = curDB.OpenRecordset(strsql1)
Do Until rs.EOF
For Each F In rs.Fields
If rs.Fields(F.Name) <> rs1.Fields(F.Name) Then
'rs.Edit
strsql = "Select * into test from " & tablename1 & " where " & F.Name & " = """ & rs.Fields(F.Name) & """"
DoCmd.RunSQL strsql
If DCount(F.Name, "test") <> 0 Then
GoTo append_unmatch
'appending unmacthed records
append_unmatch:
strsql2 = "insert into Unmatched_records Select * from test"
DoCmd.RunSQL strsql2
'if record doesnt match move to next one
GoTo Nextrecord
End If
' rs.Fields(F.Name) = rs1.Fields(F.Name)
' rs.Update
End If
Next F
Nextrecord:
rs.MoveNext
rs1.MoveNext
Loop
'To check whether tables matched or not
final:
Dim rs2 As DAO.Recordset
strsql3 = "select * from Unmatched_records"
Set rs2 = curDB.OpenRecordset(strsql3)
For Each F In rs2.Fields
If DCount(F.Name, "Unmatched_records") <> 0 Then
MsgBox ("The two tables didnt match. Check table Unmatched_records for unmatching reocrds.")
Else
MsgBox ("Tables match!")
End If
Exit Sub
Next F
rs2.Close
End Sub
Private Sub Form_Load()
Text20.Enabled = False
Text18.Enabled = False
Text18.Value = ""
Text20.Value = ""
End Sub