Hi,
I have an Access database (in Access 2003) with several tables, and data must be imported to Sql Server 2005. Access data does not have the same structure as sql server database, so I created various queries which transforms it to format needed by Sql Server. Basically for each table in sql server I have two queries: a Select query which generates the fieldnames and types compatible with sql table, and an Append query which basically does
Insert into [Sql_table] (field1, field2, ...)
Select [field1, field2, ...] from [Access_table]
Both Sql and original access tables have primary key Autoinc, and I include it in the query.
When I run the insert query and the source select query have not very many records (up to few hundreds) all works ok, the records are inserted ok, with the original identity
But when the source query have more records (I have few tables with over 10000 records), I have two situations:
either Access reports the query cannot add any records to sql server due to primary key violation (but there is no violation at all). In this case I simply close access and restart it ... and I get to second situation
running the query Access tells me it cannot import x records (usually few, 10, 21, 32, usually seems random number up to 100 out of 10000+) due to primary key violation, but imports the rest. Again, there's no key violation anyway, all ID's are unique, as generated in original Access table by autoinc field. The strange thing is , if I delete sql data and run query again, I get different number of records not imported, sometimes few, sometimes more, but all in range of 10-50 out of 10000
I tried with Access 2007 too, but the same thing happens.
The Sql server table has foreign key relation to a master table, but this relation is also satisfied by data I try to import.
Does anyone knows faced this problem and know for a solution?
Thanks
PS: I don't use sql server import wizard since there will be way to much work to convert access data through sql server - the access select queries are already made, they are quite complex, use some functions written in VBA, which would be difficult to rewrite to tsql just for this only purpose