Solved

Update Statement Using Info From Another Table

Posted on 2006-11-22
3
206 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
  • 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 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

12 Experts available now in Live!

Get 1:1 Help Now