Solved

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

Posted on 2009-05-06
6
282 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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now