SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 update query
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

mateenmohd
Constraint Violating Yak Guru

United Arab Emirates
297 Posts

Posted - 08/24/2004 :  03:21:47  Show Profile
update (insert) data from one table to another table.

employees table
------------------
empno joindate
1234
1235
1236
.......


info table
------------------
empno joindate
1234 3/11/2003
1235 6/10/2002
1236 9/12/2000
.....



how can update (insert) the employees table column joindate with the info table column joindate ?
I want to insert (update) info table joindate into employees table.
insert all joindate into employees joindate where employees.empno=info.empno

update employees
set joindate =
from info
where employees.empno=info.empno
and joindate is null

regards.

Mateen


spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 08/24/2004 :  04:28:26  Show Profile  Visit spirit1's Homepage
this should do the update:

update e
set e.joinDate = i.joinDate
from employees e
inner join info i on (e.empno = i.empno)


Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

mateenmohd
Constraint Violating Yak Guru

United Arab Emirates
297 Posts

Posted - 08/25/2004 :  06:24:10  Show Profile
thanks for response.

it doble the records.
I have four hundred records, after run this query
it show eight hundred records why ?

Mateen
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11750 Posts

Posted - 08/25/2004 :  06:38:40  Show Profile  Visit spirit1's Homepage
well, with out more info there's not really much to say.
post the create table, insert into (sample data), and desired results so we can test it on our machines and give the answer.

Go with the flow & have fun! Else fight the flow :)

Edited by - spirit1 on 08/25/2004 06:49:39
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000