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 2000 Forums
 Transact-SQL (2000)
 Update from one table to another

Author  Topic 

poser
Posting Yak Master

124 Posts

Posted - 2008-11-07 : 11:07:26
Hello, and yes I'm still just learning ;)

I have two tables
EmpID match in both tables so can be joined by them.

Table 1: Employee
Columns are EmpID IsHere IsNotHere
1 Y N
2 N Y

Table 2: Employee1
Columns are EmpID IsHere IsNotHere
1 N N
2 Y N

I need to update Employee1.IsHere, Employee1.IsNotHere

From Employee.IsHere, Employee,IsNotHere

There are a thousand rows in my table.

TIA/P

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-07 : 11:10:11
[code]UPDATE t1
SET t1.IsNere=t2.IsHere,
t1.IsNotHere=t2.IsNotHere
FROM table1 t1
INNER JOIN table2 t2
ON t2.EmpID=t1.EmpID[/code]
Go to Top of Page

poser
Posting Yak Master

124 Posts

Posted - 2008-11-07 : 11:58:30
Thank you, Thank you, Thank you...

R/P
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-07 : 12:00:22
Cheers,Cheers,Cheers...
Go to Top of Page
   

- Advertisement -