Solved

Compare & Update Dates In Two Tables

Posted on 2011-02-18
2
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why I am having this error in my query? 2 32
Disable TLS1.0 on Win 2012 server 7 60
How can I get the entire database script? 7 24
denied execute as 13 27
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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