Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update column from one table to another

Author  Topic 

TP_MMo
Starting Member

1 Post

Posted - 2009-05-13 : 10:14:18
The SQL person just left and I'm left holding the bag until they are replaced.

In the meantime I need to update a column in a table using data from another table using SQL Management Studio. Logically this seems easy, but I am having trouble executing it.

I have two tables with ContID (unique identifier) and DoNotMail in common. I need to update the DoNotMail column in Table_2009 using the DoNotMail information from Table_2008 based upon the ContID. ContID is not in exact order across both tables and has approx 300,000 records.

Here is an example of my tables:

Table_2008
ContID
212231000074
212091002335
180611000746
212151001092
212151001090

DoNotMail
NULL
X
X
NULL
NULL

Table_2008
ContID
180611000746
212091002335
212151001090
212231000074
212151001092

DoNotMail
NULL
NULL
NULL
NULL
NULL

Please help!
Thanks,
Mary

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-13 : 10:19:43
[code]UPDATE t2
SET t2.DoNotMail =t1.DoNotMail
FROM Table_2008 t1
JOIN Table_2009 t2
ON t2.ContID =t1.ContID [/code]
Go to Top of Page
   

- Advertisement -