473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Append Query from Access to SQL Server

I have created an append query in my MSAccess front end to the linked table in SQL Server. There is an ID field which is common in the query that is type autonumber/identity. If I do not include the ID field in the query, SQL Server gives me an error that indicates that I need to explicitly provide a value. (for an auto number field??) If I include the ID field in the query, I have to provide a unique number as an ID* - instead of SQL Server generating the next value in the sequence.

I cannot figure out how to append records with the query and allow SQL Server to provide the automatic values in the ID field.
Any suggestions? (sql code below)
I guess I could write code to copy each record over one at a time - but I would rather have the query handle it if possible. Maybe I will have to make the update in SQL Server instead of running it from MSAccess...

*I am surprised that I am allowed to input a value for a field that is supposed to automaticaly create a value. I can do this for one record, but the next record that is input normally will increment the automatic value from the value I entered thru the query instead of continueing from the last auto number.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [tbl:issues] ( IssueID, issuenumber, issuedesc, issuestatus )
  2. SELECT 290014 AS exp, 999 AS IssNum, [qry:OpenIssues].issuedesc, [qry:OpenIssues].issuestatus,  
  3. FROM [qry:OpenIssues]
  4. WHERE ((([qry:OpenIssues].SolutionTestID)=[Forms]![frm:IssueForward]![PreviousTestID]));
thanks
rick
Mar 19 '07 #1
4 4822
iburyak
1,017 Expert 512MB
Can you create pass-through query in Access?
This way you would be able to use native SQL and ID will be auto-generated.

Good Luck.
Mar 20 '07 #2
There is a pass-thru query option in MSAccess. I am not familiar with it, but I will give it a try - see if I can figure out how to use it.
Mar 20 '07 #3
iburyak
1,017 Expert 512MB
What it does. When you create a pass-through query it doesn't check syntax on Access side and passes it to the server as is to execute. On the server side code executed and if syntax is correct it will work. If query is not pass-through it will check syntax first and will not recognize table names that are on SQL side for example or just differences between syntax will be impossible to work with.
Not sure thou how to pass parameters to this query but if you can create it on a fly it is the best bet. Need some research and programming skills…. :)

You probably better off using something like ADO to insert records directly.

Good Luck.
Mar 20 '07 #4
OK - sounds like I need to write the Access SQL with syntax that works on SQL Server and save it as a pass thru query. Since some of the query parameters are derived from Access form controls , I am not sure this will work.

What I am trying to accomplish is to copy test issues that were not resolved from a closed test project - to the next project, so the issue can continue to be worked. When a new test project is created, the tester picks an old test project from a combo box to drive which open issues should be forwarded to the new project.
Mar 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
1
by: Kristina | last post by:
I'm trying to run multiple append queries in an Access front end that append data from tables in a .mdb into tables in SQL Server 2000. My Access front end has a link to both tables, the .mdb and...
6
by: dd_bdlm | last post by:
Hi all I have a database that stores customer records and their associated insurance details. I need to be able to archive any changes made to that record. Currently the user selects 'record...
5
by: Michael C via AccessMonster.com | last post by:
Hello, I have a table that I am appending 3 seperate tables into. My main problem is that each time I append the data, it simply adds to the data already there. That might sound ok, except that...
4
by: robboll | last post by:
When I try to use an append query from an oracle link it takes forever. I am exploring the idea of doing an append action using a pass-through query. If I have an Oracle ODBC connection to...
7
by: pltmcs | last post by:
I am trying to generate some records from one table into another. The problem is that the new table has an autonumber field (PID). The PID is part of the primary key since it is possible to have...
2
by: TroutmansRegistrar | last post by:
I have a web programming task that has me stumped. I hope that one of you could give me some insight or might know someone who could guide me in the right direction. This is the final piece of the...
3
by: hikosj | last post by:
Hi all, I have a problem with a query in access that I cant seem to figure out. I have a form named frmRecruitment with a subform named sfrmParticipant. At the moment I am using an append query to...
10
by: MeeMee | last post by:
Hi I have a problem appending data into an oracle table from access. I imported the new data from an excel sheet into a table in access and useed an append query to add the data into a linked...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.