Solved

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

Posted on 2009-05-06
6
284 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

735 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