Click here to Skip to main content
15,919,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one table EMP where all information of employee are there.
EMP columns are:

EMPID
Lname
Fname
Department
Designation


And i have one more table called info.
Info columns are:
Empid
fname
departrment

EMP.EMPID=Info.EMPID

In info table EMPID are coming randomly from other table.Now in Info table only EMPID is there,so i want to fill other column of info table from EMP table whose EMPID is present on Info table...
Posted

Your question is not clear for me.
If you want to update info table by EMP table's data, you can use "update ~ from" query.

In Normalize viewpoint, you should not store same data in different table.
 
Share this answer
 
Comments
Maciej Los 5-Aug-13 2:24am    
Agree! +5
The correct structure of database should looks like:
EMP (EmpID, Fname, Lname, DepId)
DEP (DepID, Dname)
Try this code.

SQL
update  i
 set fname=e.Fname,departrment=e.Department
 from emp e , Info i
 where e.Empid= i.Empid
 
Share this answer
 
Comments
Nawab Ahmad 5-Aug-13 3:35am    
Hi,
In my emp table i have like this
EmpId fname department
----- ----------- ---------
253 nawab software
123 ahmad programmer
147 xyz production


And in my info Table:
EmpId Fname department
----- ----------- ---------
253
123

so i want to fill the information in info table related to emp table,information of those guys whose id is present in the info table.
ArunRajendra 5-Aug-13 4:12am    
Yes the given query will update the fields in Info table?
Nawab Ahmad 5-Aug-13 4:36am    
But when i m executing this query it is showing error .......
plz help..
ArunRajendra 5-Aug-13 5:39am    
what is the error?
Nawab Ahmad 5-Aug-13 23:38pm    
Msg 207, Level 16, State 1, Line 5
Invalid column name 'Empid'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900