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 |
kbchan
Starting Member
1 Post |
Posted - 2007-06-30 : 10:24:49
|
Hi there, My problem should be fairly simple. Say i have a small table with 2 columns, employee_id and department_id. I want to create a check constraint so that no more than 4 employee_id can be associated with department_id and the user is warned if he/she is trying to do so. Can anyone advise me on how to do it? Regards,Kam |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-06-30 : 20:40:33
|
You may need trigger for that. |
 |
|
pootle_flump
1064 Posts |
Posted - 2007-07-05 : 05:48:16
|
quote: Originally posted by kbchan Hi there, My problem should be fairly simple. Say i have a small table with 2 columns, employee_id and department_id. I want to create a check constraint so that no more than 4 employee_id can be associated with department_id and the user is warned if he/she is trying to do so. Can anyone advise me on how to do it? Regards,Kam
You can do this by referring to the output of a function in the check constraint. Look up CHECK CONSTRAINTS in BoL and there is an example of just what you want to do. |
 |
|
|
|
|