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

Update Query (Access vs. SQL Server)

Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ra*********@hotmail.com)

================

UPDATE INVENTORY

INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)

AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR)

SET INVENTORY.DATE_PURCHASED = "20050127"
WHERE (((SALES.SOLD)="20050127"));

Nov 13 '05 #1
6 4810
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use single quotes in SQL queries for delimited values. Double-quotes
have a different meaning.

UPDATE inventory
SET date_pruchased = '20050127'
FROM inventory i INNER JOIN sales s
on i.bar_code = s.bar_code and i.product_nbr = s.product_nbr
WHERE s.sold = '20050127'

Probably better could be:

UPDATE inventory
SET date_pruchased = s.sold
FROM inventory i INNER JOIN sales s
on i.bar_code = s.bar_code and i.product_nbr = s.product_nbr
WHERE s.sold = '20050127'

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQfl8xYechKqOuFEgEQJvPQCfUihJUy2SoOV6PB3sT2R8mo 6FVwMAoM2B
wvfAWGq5a8VVEgR7zuQef8uH
=UKJw
-----END PGP SIGNATURE-----
ra*********@hotmail.com wrote:
Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ra*********@hotmail.com)

================

UPDATE INVENTORY

INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)

AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR)

SET INVENTORY.DATE_PURCHASED = "20050127"
WHERE (((SALES.SOLD)="20050127"));

Nov 13 '05 #2
ra*********@hotmail.com wrote:
Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ra*********@hotmail.com)

================

UPDATE INVENTORY

INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)

AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR)

SET INVENTORY.DATE_PURCHASED = "20050127"
WHERE (((SALES.SOLD)="20050127"));


SQL Server won't update on a join.

update inventory
SET INVENTORY.DATE_PURCHASED = '20050127'
where exists(select * from sales where sales.product_nbr =
inventory.product_nbr and sales.sold='20050127')
--
This sig left intentionally blank
Nov 13 '05 #3
Trevor Best wrote:
SQL Server won't update on a join.

update inventory
SET INVENTORY.DATE_PURCHASED = '20050127'
where exists(select * from sales where sales.product_nbr =
inventory.product_nbr and sales.sold='20050127')


ALTER PROCEDURE UPDATESchoolSubjectIDGlobal
@SchoolID int,
@SubjectID int
AS
UPDATE
t
SET
t.SubjectID = @SubjectID
FROM
TimeTable t
JOIN
SchoolTeachers st
ON
t.TeacherID = st.TeacherID
WHERE
st.SchoolID = @SchoolID
RETURN
Nov 13 '05 #4
Trevor Best <no****@besty.org.uk> wrote in news:41f9f700$0$26019
$f*******@news.zen.co.uk:
ra*********@hotmail.com wrote:
Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ra*********@hotmail.com)

================

UPDATE INVENTORY

INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)

AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR)

SET INVENTORY.DATE_PURCHASED = "20050127"
WHERE (((SALES.SOLD)="20050127"));


SQL Server won't update on a join.

update inventory
SET INVENTORY.DATE_PURCHASED = '20050127'
where exists(select * from sales where sales.product_nbr =
inventory.product_nbr and sales.sold='20050127')


ALTER PROCEDURE UPDATESchoolSubjectIDGlobal
@SchoolID int,
@SubjectID int
AS
UPDATE
t
SET
t.SubjectID = @SubjectID
FROM
TimeTable t
JOIN
SchoolTeachers st
ON
t.TeacherID = st.TeacherID
WHERE
st.SchoolID = @SchoolID
RETURN

Please, accept my apologies if I have posted this twice.

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.
Nov 13 '05 #5
Lyle Fairfield wrote:
Trevor Best <no****@besty.org.uk> wrote in news:41f9f700$0$26019
$f*******@news.zen.co.uk:

ra*********@hotmail.com wrote:
Can someome please advise what the equivalent query would be in
Microsoft SQL Server ... I've tried a number of combinations with no
success ... Thanks, Ralph Noble (ra*********@hotmail.com)

================

UPDATE INVENTORY

INNER JOIN SALES ON (INVENTORY.BAR_CODE = SALES.BAR_CODE)

AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR)

SET INVENTORY.DATE_PURCHASED = "20050127"
WHERE (((SALES.SOLD)="20050127"));


SQL Server won't update on a join.

update inventory
SET INVENTORY.DATE_PURCHASED = '20050127'
where exists(select * from sales where sales.product_nbr =
inventory.product_nbr and sales.sold='20050127')

ALTER PROCEDURE UPDATESchoolSubjectIDGlobal
@SchoolID int,
@SubjectID int
AS
UPDATE
t
SET
t.SubjectID = @SubjectID
FROM
TimeTable t
JOIN
SchoolTeachers st
ON
t.TeacherID = st.TeacherID
WHERE
st.SchoolID = @SchoolID
RETURN

Please, accept my apologies if I have posted this twice.


I was unaware of that syntax.

--
This sig left intentionally blank
Nov 13 '05 #6
SQL Server will update on a join, but the query designer window in
Enterprise Manager doesn't like that syntax/won' t represent it
graphically. It is also a little different from Access sql. It will
complain if you feed it an update with a join by graying out the the
diagram and grid panes, but it will execute just fine.

UPDATE INVENTORY
SET DATE_PURCHASED = '1/27/2005'
FROM INVENTORY, SALES WHERE (INVENTORY.BAR_CODE = SALES.BAR_CODE)
AND (INVENTORY.PRODUCT_NBR = SALES.PRODUCT_NBR) AND (SALES.SOLD =
'1/27/2005')

Nov 13 '05 #7

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

Similar topics

2
by: The Plankmeister | last post by:
Hi there... Is it possible to write an UPDATE or INSERT query, where the new value comes from an array? For example: UPDATE table_a SET column_x = WHERE column_y = ; It's a query (for...
4
by: Scott Berry | last post by:
This is a little frustrating, because it should be easy. I have an application that has been converted to SQL Server 2000 from MS Access 97. New data is loaded each week and one of my old queries...
6
by: mo | last post by:
I need to bring the ssn's into UniqueSups (supervisors) from tblNonNormalized. My inherited DB is not normalized and I find it extremely irritating due to the workarounds needed. I created...
4
by: meyvn77 | last post by:
Im using an ADP to connect to a SQL Sqever DB. In access it was really easy to say Inner join on table1 and table2 and update columnA from table1 with columnC from table2 where table1.key =...
10
by: Steve Jorgensen | last post by:
Hi all, Over the years, I have had to keep dealing with the same Access restriction - that you can't update a table in a statement that joins it to another non-updateable query or employs a...
4
by: René Kabis | last post by:
People, I am at my wit's end. I am using the exact code from http://aspnet.4guysfromrolla.com/articles/071002-1.aspx And yet, the code does not manage to update the database. When I go to...
2
by: ILCSP | last post by:
Hello, I have the following query in Access 2000 that I need to convert to SQL 2000: UPDATE tblShoes, tblBoxes SET tblShoes.Laces1 = Null WHERE (((tblShoes.ShoesID)=Int(.)) AND...
7
by: Stephen Martinelli | last post by:
Can anyone tell me why this statement works with sql server with VB.net but crashes when run against a access mdb?....What do I need to change here guys? Update tblInvoice set ar_totalPaid =...
5
by: teddysnips | last post by:
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...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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
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...

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.