More DB2 Date Conversion Issues Importing Primary Keys into SQL Server

Comments 0

Share to social media

In a previous blog entry (Date Errors Pulling DB2 Data into SQL Server) I recounted some of the issues I had with date conversions from DB2 to SQL Server.  Another interesting issue came up.  We were pulling data from a production DB2 database and continued getting duplicate primary key violations on a few records in some of the tables.  My initial reaction was that the client had done something crazy and somehow managed to really mess up their data.  But after taking a look at the tables in which the error was occurring, we found out that all of those tables had Date columns as part of the primary key.  DB2 dates apparently have more precision than SQL Server.  On some records, the loss of precision made some of the primary keys non-unique, causing the error.  Whoops.  Just another issue to look for if you’re having DB2 conversion issues.

Load comments

About the author

Damon Armstrong

See Profile

Damon Armstrong is a consultant with SystemwarePS in Dallas, Texas. He is also a blogger and author of Pro ASP.NET 2.0 Website Programming and SharePoint 2013 Essentials for Developers. He specializes in the Microsoft stack with a focus on web technologies like MVC, ASP.NET, JavaScript, and SharePoint. When not staying up all night coding, he can be found watching a bunch of kids, studying Biblical topics, playing golf, or recovering from staying up all night coding.