?
Solved

Update Statement Using Info From Another Table

Posted on 2006-11-22
3
Medium Priority
?
244 Views
Last Modified: 2008-03-06
I have 4 colomns in table1 (table1.column1, table1.column2, table1.column3,  table1.column4) that I want overwritten by the same 4 columns in table2 (table2.column1, table2.column2, table3.column3,  table2.column4).

The 4 columns need to be changed only when the following criteria is met:

WHERE table1.campaign = table2.campaign
and table1.[ad group] = table2.[ad group]
and table1.[report type] = table2.[report type]
and table1.campaign = table2.campaign
and table1.[adgroup status] = table2.[adgroup status]
and table1.[creative status] = table2.[creative status]
and table1.[campaign status] = table2.[creative status]

How do i accomplish this?

thanks
 
0
Comment
Question by:restockit
[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
3 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 2000 total points
ID: 18000277
Hi restockit,

try this:

UPDATE table1 t1
set
    t1.column1 = t2.column1,
    t1.column2 = t2.column2,
    t1.column3 = t2.column3,
    t1.column4 = t2.column4
FROM
    table2 t2
WHERE table1.campaign = table2.campaign
and table1.[ad group] = table2.[ad group]
and table1.[report type] = table2.[report type]
and table1.campaign = table2.campaign
and table1.[adgroup status] = table2.[adgroup status]
and table1.[creative status] = table2.[creative status]
and table1.[campaign status] = table2.[creative status]


Cheers,
Hillwaaa
0
 

Author Comment

by:restockit
ID: 18000384
thanks!!
0
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 18000391
No worries!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

764 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