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 |
|
thealley
Starting Member
5 Posts |
Posted - 2008-02-10 : 11:52:27
|
| Hi all,Can someone show me how to do a trigger to check that all variables of a particular column in one table should be mandatorily present in another table?For example, I have an Employee table (EmpId, Name, Surname) and a Project table (ProjId, Proj_Name). Now I want that each employee should be assigned to at least one project, else it cannot exist in the Employee table.Thanks for your help. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-10 : 12:43:40
|
| For checking the reqd. condition you need a field in employee table connecting to project table or there should be a connecting table b/w the two. As of now, i cant see any such relationship. Can you post more info on how relationship is set? |
 |
|
|
thealley
Starting Member
5 Posts |
Posted - 2008-02-10 : 16:59:32
|
| Hi visakh16,Let's say I have: tblEmployee(EmpId(PK), Name, Surname)tblProject(ProjId(PK), Proj_Name)tblAssignedProjects(EmpId, ProjId) - both foreign keysNow I want a trigger or something to check that each Employee is assigned at least one Project (in tblAssignedProjects) or else it could not exist in tblEmployee.Thanks. |
 |
|
|
|
|
|