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 |
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2006-03-08 : 16:06:40
|
| I have 2 tablesEMP(empid,dep,jobid,sec)JOB(jobid,dep)How can i have a trigger where it has to insert dep from JOB into EMP where it matches jobid in both tables ,when ever EMP table is updated |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-03-08 : 16:33:12
|
| That's a bad idea. You have a denormalized table design. There is no need to have DEP in the EMP table.Since you have a foreign key in the EMP table to the JOB table, you can just join to the JOB table to get DEP.CODO ERGO SUM |
 |
|
|
supersql
Yak Posting Veteran
99 Posts |
Posted - 2006-03-09 : 07:38:37
|
| Here Dep is a fk in table JOB from the table DEPT.DEPT is the parent table for Dep.jobid in EMP table is the fk for JOB table, Now I have to update Dep in EMP table by matching Dep with JOB table.If jobid=1, Dep=5 in table JOB then It shud also be jobid=1, Dep=5 in EMP table. |
 |
|
|
|
|
|