Data type conversion

Automate and integrate using the SQL comparison API

Data type conversion

Postby bryantb2 » Tue Nov 01, 2011 9:31 pm

I have manually mapped 2 databases as follows:

tableMapping.FieldMappings.Add(new FieldMapping(tableMapping.Obj1.Fields["pa_firstname"], tableMapping.Obj2.Fields["FirstName"], FieldMappingStatus.Success));
tableMapping.FieldMappings.Add(new FieldMapping(tableMapping.Obj1.Fields["pa_lastname"], tableMapping.Obj2.Fields["LastName"], FieldMappingStatus.Success));
tableMapping.MatchingMappings.Add(new FieldMapping(tableMapping.Obj1.Fields["pa_id"], tableMapping.Obj2.Fields["SurrogateKey"], FieldMappingStatus.Success));

My problem is that when I call CompareDatabases I receive the following error:

RedGate.SQLCompare.Engine.SqlCompareException was unhandled
Message=Unable to compare between fields pa_id and SurrogateKey, types being compared System.Int64 and System.String.
Source=RedGate.SQLDataCompare.Engine


Is it possible to compare a field, in this case "pa_id", as a varchar type rather than its native type?
bryantb2
 
Posts: 2
Joined: Tue Nov 01, 2011 9:25 pm

Postby Chris.Allen » Thu Nov 03, 2011 1:26 pm

The thing to do here would be to cast into a view and then perform the comparison
Chris.Allen
 
Posts: 594
Joined: Thu Mar 12, 2009 4:17 pm

Postby bryantb2 » Thu Nov 03, 2011 3:01 pm

That's what we were doing as an interim solution. It would be nice if widening conversions could be handled somehow without the use of a view though.
bryantb2
 
Posts: 2
Joined: Tue Nov 01, 2011 9:25 pm


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests