Solved

Compare & Update Dates In Two Tables

Posted on 2011-02-18
2
397 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 142

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL Using IN with a subquery 3 25
Parsing out characters on the right side of hyphen 3 23
Can Unique column have more than one Null? 8 43
xpath sql query 2008 8 41
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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