Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Compare and update data between two databases

Posted on 2016-10-04
6
Medium Priority
?
107 Views
Last Modified: 2016-10-04
Hi,

I was helped by one of the members with the query below, but a closer look at the query doesn't works. Any assistance greatly appreciated. Thanks!

Here is the query:

USE Inventory
GO
UPDATE Items
SET [Available Inventory] = (SELECT [Available Inventory]
        FROM Items_Update.. Updates U
        WHERE U.[Item Number] = Items.[Item Number])


Example per screenshot:
- The query compare the 'Item Number' between the Inventory and Items_Update databases.
- If the Item Number matches, then update the "Available Inventory" number, which is 22 to the "Available Inventory" field in the Inventory database.
0
Comment
Question by:Member_2_7967487
  • 3
  • 3
6 Comments
 

Author Comment

by:Member_2_7967487
ID: 41829185
Example1.jpg
0
 
LVL 35

Accepted Solution

by:
Pawan Kumar earned 2000 total points
ID: 41829191
Pls try this..

USE Inventory
GO

UPDATE a
SET a.[Available Inventory] = U.[Available Inventory]
FROM Items a
INNER JOIN Items_Update.. Updates U
ON U.[Item Number] = a.[Item Number] 

Open in new window

0
 
LVL 35

Expert Comment

by:Pawan Kumar
ID: 41829210
Have you tried the above approach?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Member_2_7967487
ID: 41829214
I have an error.



errorA.jpg
0
 
LVL 35

Expert Comment

by:Pawan Kumar
ID: 41829216
can you provide me the schema for both the tables ?
0
 

Author Comment

by:Member_2_7967487
ID: 41829220
I updated the line below and it works!  Thank you very much, Pawan!!
[ Available Inventory ]

SET a.[Available Inventory] = U.[ Available Inventory ]
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

963 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