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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 UPDATE Statement Help

Author  Topic 

Skiggity
Starting Member

2 Posts

Posted - 2012-08-27 : 14:24:25
So I have a table in production, Teacher_Dim. There is already data populated in this table and I have added a new column that I wanted populated, Teacher_School_ID.

I have a table in staging, Teacher_Staging, that has the School_ID information that I want to place into the Teacher_Dim table.

I was hoping to write an Update statement that would populate the Teacher_School_ID column where the Teacher_Dim.Teacher_ID field = Teacher_Staging.Teacher_ID.

Anyone have any suggestions about how to write this update statement?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-27 : 14:34:20
UPDATE prod
SET Teacher_School_ID = stage.Teacher_School_ID
FROM Teacher_Dim prod
JOIN Teacher_Staging stage ON prod.Teacher_ID = stage.Teacher_ID

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Skiggity
Starting Member

2 Posts

Posted - 2012-08-27 : 14:50:59
That worked. Thank you very much for the help.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-08-27 : 14:59:22


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -