Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Compare & Update Dates In Two Tables

Posted on 2011-02-18
2
Medium Priority
?
430 Views
Last Modified: 2012-05-11
Hello Experts,

I have two tables, Jobs & GoodsReceipts. In Jobs there is an ActionDate (datetime) column which I need to compare with GoodsReceipts column Date (datetime) and if they differ, update GoodsReceipts with the new date.

I am sure the answer is very simple but I am having one of them days :(

I'm using MS SQL SERVER 2008.

Thanks,


David
0
Comment
Question by:NewFourWalls
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 34925901
update with join is explained here:
http://www.experts-exchange.com/A_1517.html

UPDATE r
  SET GoodsREceips = j.ActionDate
  FROM GoodsReceipts r
  JOIN Jobs j
    ON r.key_column = j.key_column
   WHERE r.GoodsREceips <> j.ActionDate 

Open in new window

0
 

Author Closing Comment

by:NewFourWalls
ID: 34926350
Thank you.

I used a different example from the page you sent and it works great.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

810 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