Options

Compare BACKUP to Live and Change MatchingMappings

rockywurdenrockywurden Posts: 10
edited February 1, 2008 3:40AM in SQL Toolkit Previous Versions
Problem: How do you change the MatchingMappings on a table when 1 of the databases is a SQL BACKUP.

Table3 has primary key RECID
Need to change to ROWGUID which has a unique index

map.MatchingMappings.clear
map.MatchingMappings.ADD("ROWGUID")
'Throws the following error.
*****Mappings only supports mapping objects. Parameter name: value

Thanks
Rocky

Following Code Sample see CASE TABLE3 Statement.

Dim db1 As New BackupDatabase
Dim db2 As New Database

Try
db1.RegisterForDataCompare(New String() {sFile}, Nothing)
db2.RegisterForDataCompare(New ConnectionProperties(tServer, tdatabase))
Dim mappings As New SchemaMappings
Dim map As TableMapping
mappings.CreateMappings(db1, db2)

'Exclude tables and change Index
For Each map In mappings.TableMappings
Select Case map.Obj1.Name.ToUpper
case "TABLE2"
map.Include = False
Case "TABLE3"
'This table Matching field is RECID and is the primary key.
'Need to change field to ROWGUID which has a unique index.
map.MatchingMappings.clear
map.MatchingMappings.ADD("ROWGUID")
'Throws the following error.
*****Mappings only supports mapping objects. Parameter name: value

End Select
Next map

Dim session As New ComparisonSession()
session.CompareDatabases(db1, db2, mappings)

Comments

Sign In or Register to comment.