Solved

How to catch SQL error return by a query running in Access

Posted on 2009-05-06
6
285 Views
Last Modified: 2012-05-06
Hi all,

I am working on an Access project, which will migrate data from Access to SQL Server. I do it through Append query. The issue is that, the append query sometimes couldnt insert a particular row from Access to SQL Server (I know the reason is datatype confliction), but Access didnt error out this error and just skip this row. My question is is there anyway I can catch this error, try to modify the data to be datatype-matched, and then re-insert to SQL Server table.
I tried to look for solution but havent found yet. If anyone have idea, I would appreciate.

Regards,
0
Comment
Question by:jjdahl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 84
ID: 24320228
How are you running your append query? Is this a query that you've built in the Access database, or are you opening a connection to the server, running a Stored Proc on the server, etc etc ...
0
 
LVL 84
ID: 24320234
Also, IMO you really should validate your data BEFORE you attempt your append - that is, using VBA, you'd examine your data to insure that you can correctly insert before you attempt to do so.
0
 

Author Comment

by:jjdahl
ID: 24320371
HI LSMConsulting,

I create append queries in access, with linked tables to SQL Server. Also, I create a program that automatically run those append queries.
 
This is a big migration with hundreds of table, that's why I cannot check every case to make sure data is correct. Detect the data mismatch and show it out is a part of the project too.

Thanks for your response
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84
ID: 24320685
You could build queries that would be run AFTER your insert, to show which records haven't been inserted. for example:

SELECT * FROM YourSQLTable WHERE YourIDField NOT IN (SELECT IDfield FROM YourAccessTable)

Of course, you may need to use more than one field in the subselect to get the right results, but then I'm not sure of your table structure.
0
 
LVL 18

Accepted Solution

by:
jmoss111 earned 500 total points
ID: 24321178
Why would you even want to insert incorrect data into a table if you could? Build staging tables, do hygiene on the staging tables then insert into prod tables.
0
 
LVL 84
ID: 24321285
Exactly ...
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question