Solved

Update Statement Using Info From Another Table

Posted on 2006-11-22
3
236 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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

726 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