473,387 Members | 1,455 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,387 software developers and data experts.

Help with rewriting Access UPDATE query to be SQL Server compliant

Having upsized my client's back-end DB to SQL Server, the following
query does not work ("Operation must use an updateable query").

UPDATE tblbookings INNER JOIN tblREFUNDS ON tblbookings.TransFromID =
tblREFUNDS.BookingID SET tblREFUNDS.[MOVED TO NEW BKREF] = tblbookings!
bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null));

I tried rewriting it as follows, with the same problem:

UPDATE tblRefunds, tblBookings
SET [MOVED TO NEW BKREF] = tblbookings.bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null)) AND (tblREFUNDS.BookingID =
tblbookings.TransFromID );

In SQL Server's QA the following flavour works:

UPDATE tblREFUNDS
SET tblREFUNDS.[MOVED TO NEW BKREF] = b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID
WHERE (((r.[MOVED TO NEW BKREF])=0) AND ((b.TransFromID) Is Not
Null));

but if I paste this into an Access query I get a "Syntax error
(missing Operator) in b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID"

I am (and more importantly my client is) getting increasingly
frustrated with this. One obvious method would be to move the query
to a Stored Procedure, but there are various reasons why I don't want
to do this (mainly to do with the client being able to maintain the
system).

Has anyone any thoughts on how to rewrite the original query as an
Access query without creating a Passthrough Query?

Many thanks

Edward
Jun 27 '08 #1
5 2041
On Apr 30, 2:55*am, teddysn...@hotmail.com wrote:
Having upsized my client's back-end DB to SQL Server, the following
query does not work ("Operation must use an updateable query").

UPDATE tblbookings INNER JOIN tblREFUNDS ON tblbookings.TransFromID =
tblREFUNDS.BookingID SET tblREFUNDS.[MOVED TO NEW BKREF] = tblbookings!
bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null));

I tried rewriting it as follows, with the same problem:

UPDATE tblRefunds, tblBookings
SET [MOVED TO NEW BKREF] = tblbookings.bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null)) AND (tblREFUNDS.BookingID =
tblbookings.TransFromID );

In SQL Server's QA the following flavour works:

UPDATE tblREFUNDS
SET tblREFUNDS.[MOVED TO NEW BKREF] = b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID
WHERE (((r.[MOVED TO NEW BKREF])=0) AND ((b.TransFromID) Is Not
Null));

but if I paste this into an Access query I get a "Syntax error
(missing Operator) in b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID"

I am (and more importantly my client is) getting increasingly
frustrated with this. *One obvious method would be to move the query
to a Stored Procedure, but there are various reasons why I don't want
to do this (mainly to do with the client being able to maintain the
system).

Has anyone any thoughts on how to rewrite the original query as an
Access query without creating a Passthrough Query?

Many thanks

Edward
what's the problem with using a passthrough query ?
Jun 27 '08 #2
On 30 Apr, 11:17, Roger <lesperan...@natpro.comwrote:
On Apr 30, 2:55*am, teddysn...@hotmail.com wrote:
[...]
what's the problem with using a passthrough query ?- Hide quoted text -
The database was developed by a gifted amateur, who more or less
taught herself Access as she went along. I've been asked to do the
upsizing to SQL Server, but I want to keep any modifications to the
front end as simple and close to standard Access as possible.

Edward
Jun 27 '08 #3
"Roger" <le*********@natpro.comwrote
what's the problem with using a passthrough query ?
The usual problem with a passthrough query is that Access/Jet-ACE has its
own dialect of SQL, and the back-end servers all have their own dialects of
SQL. Unless the users go 'way out of their way to adhere to ANSI-standard
or world-wide-standard SQL (and, it is amazing how many, even when their
projects claim "industry-standard", do not) those will not be the same.
Some developers or SQL-addicted-hobbyists may revel in knowing second-nature
all the major / minor / obvious / subtle differences, but typical users
(and, I suspect, typical developers) generally limit their scope to one
"dialect".

Jet and ODBC, in my experience, translate Jet SQL to surprisingly "good",
efficient server SQL when the user creates the Query in Access. It's not as
good as a 'rockstar' DBA or server Developer could do in a world-class
competition, but better than one might expect.

Larry Linson
Microsoft Office Access MVP
Jun 27 '08 #4
On Apr 30, 4:49*am, teddysn...@hotmail.com wrote:
On 30 Apr, 11:17, Roger <lesperan...@natpro.comwrote:
On Apr 30, 2:55*am, teddysn...@hotmail.com wrote:
[...]
what's the problem with using a passthrough query ?- Hide quoted text -

The database was developed by a gifted amateur, who more or less
taught herself Access as she went along. *I've been asked to do the
upsizing to SQL Server, but I want to keep any modifications to the
front end as simple and close to standard Access as possible.

Edward
ok, using access97, I created 2 tables with two fields each (removing
spaces in field names) and this query runs with no problem

tblBookings
transFromId bookingId
1 2

tblRefunds
bookingId movedToNewBkref
1 0
UPDATE tblbookings INNER JOIN tblREFUNDS ON tblbookings.TransFromID =
tblREFUNDS.BookingID SET tblREFUNDS.MOVEDTONEWBKREF = tblbookings!
bookingid
WHERE (((tblREFUNDS.MOVEDTONEWBKREF)=0) AND
((tblbookings.TransFromID) Is Not Null));

after running the query, movedToNewBkref = 2

so I'm not sure why you're getting this error
Jun 27 '08 #5
On Apr 30, 3:55 am, teddysn...@hotmail.com wrote:
Having upsized my client's back-end DB to SQL Server, the following
query does not work ("Operation must use an updateable query").

UPDATE tblbookings INNER JOIN tblREFUNDS ON tblbookings.TransFromID =
tblREFUNDS.BookingID SET tblREFUNDS.[MOVED TO NEW BKREF] = tblbookings!
bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null));

I tried rewriting it as follows, with the same problem:

UPDATE tblRefunds, tblBookings
SET [MOVED TO NEW BKREF] = tblbookings.bookingid
WHERE (((tblREFUNDS.[MOVED TO NEW BKREF])=0) AND
((tblbookings.TransFromID) Is Not Null)) AND (tblREFUNDS.BookingID =
tblbookings.TransFromID );

In SQL Server's QA the following flavour works:

UPDATE tblREFUNDS
SET tblREFUNDS.[MOVED TO NEW BKREF] = b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID
WHERE (((r.[MOVED TO NEW BKREF])=0) AND ((b.TransFromID) Is Not
Null));

but if I paste this into an Access query I get a "Syntax error
(missing Operator) in b.bookingid
FROM tblREFUNDS r INNER JOIN tblBookings b ON b.TransFromID =
r.BookingID"

I am (and more importantly my client is) getting increasingly
frustrated with this. One obvious method would be to move the query
to a Stored Procedure, but there are various reasons why I don't want
to do this (mainly to do with the client being able to maintain the
system).

Has anyone any thoughts on how to rewrite the original query as an
Access query without creating a Passthrough Query?

Many thanks

Edward
I think the query you wrote in QA will work in Access if you get rid
of the table aliases 'r' and 'b' or create the aliases using
'as' (e.g. 'tblBookings as b' and 'tblRefunds as r'). The Access
syntax is a little bit different than the TSQL syntax but I don't
recall the exact differences.

Did you recreate your unique indexes on the SQL side? Both tables
being joined must have unique indexes. I do not trust the upsizing
wizards to get this right, if that's what you used to move your data
to SQL server.

Bruce
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
0
by: Lee | last post by:
Hi all ;) Preamble -------- I'm using URL rewriting to enforce a frames policy (yeah, I know frames are 'bad' :) - i.e. if a request comes in for a page which should be nested within a...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
2
by: cryon.b | last post by:
Hi To All, I took up the IBM sample testfor Exam 700 today and I have the test tomorrow,I have some questions for which Iam not sure about the right answer,can anyone please guide me as to what is...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
1
miffe
by: miffe | last post by:
Greetings, I've got an access database on a server, and in a client PC I've got an excel spreadsheet... I run a query from the client PC involving some maths to develop different price lists from...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.