Solved

Help with Query Syntax for Update Query

Posted on 2014-07-31
2
224 Views
Last Modified: 2014-07-31
I am trying to update all of one field's table to another field's data based upon a link between the two tables.:

UPDATE CustSalesByPartPastYearTemp SET CustItem = (SELECT [CUST ITEM #] FROM [INVOICE DETAILS] INNER JOIN CustSalesByPartPastYearTemp ON [INVOICE DETAILS].[LINESERIAL#] = CustSalesByPartPastYearTemp.LineSerial)

Basically, I want the field CustItem in table CustSalesByPartPastYearTemp to equal what the field CUST ITEM # in the table INVOICE DETAILS is by linking the fields LineSerial and LINESERIAL#.

This gives an error saying :Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

I am attempting to run this on an .asp page, sql-2000 is the back end database.
0
Comment
Question by:dzirkelb
2 Comments
 
LVL 1

Accepted Solution

by:
Dukster131 earned 500 total points
ID: 40231783
You should be able to do something like this if I understand you correctly

UPDATE  t
Set CustItem = [CUST ITEM #]
from CustSalesByPartPastYearTemp t
inner join [INVOICE DETAILS] d on t.CustItem = d.[CUST ITEM#]
INNER JOIN CustSalesByPartPastYearTemp p on p.LineSerial = d.[LINESERIAL#]
0
 

Author Comment

by:dzirkelb
ID: 40231903
Thanks.  Your post led me to the following working code:

UPDATE CustSalesByPartPastYearTemp SET CustItem = [CUST ITEM #] FROM CustSalesByPartPastYearTemp INNER JOIN [INVOICE DETAILS] on CustSalesByPartPastYearTemp.LineSerial = [INVOICE DETAILS].[LINESERIAL#]
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

747 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

10 Experts available now in Live!

Get 1:1 Help Now