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.
| Author |
Topic |
|
Jonny1409
Posting Yak Master
133 Posts |
Posted - 2007-10-02 : 10:35:54
|
Hello,I have two tables in my DB - Staging (100 records) and EEDetails (1200 records)I'd like to do an update statement which will update the TeamID field in EEDetails with the relevant TeamID in Staging, but only for those records that are in the Staging table.I've tried the following code, and it worked, but for those that weren't in Staging, it set their TeamID field to <NULL>.Can anyone help me with the syntax please ?update dbo.tbl_EEDetailsset TeamID = ( selectTeamIDfrom dbo.Stagingwhere AutoRef = dbo.tbl_EEDetails.TechnicianID) Thanks in advance |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-02 : 10:38:14
|
This perhaps?update Uset TeamID = S.TeamIDFROM dbo.Staging AS S JOIN dbo.tbl_EEDetails AS U ON S.AutoRef = U.TechnicianID Kristen |
 |
|
|
Jonny1409
Posting Yak Master
133 Posts |
Posted - 2007-10-02 : 10:44:25
|
| Thanks Kristen - that worked a treat.I'm so new at this I'm struggling to get my head around Syntax, but the people on here have been so helpful. |
 |
|
|
|
|
|