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 |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2010-04-08 : 23:28:36
|
| if i have two tables Salesteam and Department.Department has departmentname, departmentidsalesteam has SalesTeamID, SalesTeamEmployee, SalesTeamDepartmentdepartments can have lots of SalesTeamEmployees but each SalesTeamEmployees can only belong to one departmenthow do i set this up? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2010-04-08 : 23:44:30
|
| i need to know how to limit the salesteam member to one departmnent only |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-04-09 : 00:21:55
|
| One way to acheive this is using triggers.In the Trigger code you can check using inserted table whether the salesteam employee is already assigned to any dept or not and take action accordingly.Regards,PramodI am here to learn from masters and help new bees in learning. |
 |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2010-04-09 : 00:24:49
|
| can you do it with some kind of unique constraint |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-04-09 : 00:59:26
|
| If i understand correctly then you have 3 tables together.Department -> Holding department informationEmployee -> Holding Employee information.SalesTeam -> Holding combination of both.If my understanding is correct then you can try creating an unique constraint for SalesTeam on SalesTeamEmployeeRegards,PramodI am here to learn from masters and help new bees in learning. |
 |
|
|
|
|
|