Compare BACKUP to Live and Change MatchingMappings

Forum for users of SQL Toolkit 3,4,and 5

Compare BACKUP to Live and Change MatchingMappings

Postby rockywurden » Thu Jan 31, 2008 7:18 pm

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)
rockywurden
 
Posts: 6
Joined: Mon Dec 10, 2007 11:01 pm

Postby richardjm » Fri Feb 01, 2008 9:40 am

If you get the sample projects available from the reference help here...

http://help.red-gate.com/help/SQLDataCo ... /index.htm

In the TableMappingExample.cs there's a full example of changing the fields to be compared. Although as you're comparing to a backup you can only use indexes and not custom comparison keys. The call you're interested in is TableMapping.UseIndexForMapping

HTH
Richard Mitchell
Project Manager
Red Gate Software Ltd
richardjm
 
Posts: 395
Joined: Fri May 20, 2005 9:44 am
Location: Red Gate Software Ltd


Return to SQL Toolkit Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests