| Author |
Topic |
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-06 : 03:42:33
|
| Department_ID nvarchar(2)Possition_ID nvarchar(2)give me code to solve : with each Department_ID have only <=1 Department manager (Possition_ID='00')thanks |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-12-06 : 03:47:20
|
| SELECT Department_ID FROM YourTable WHERE Possition_ID = '00'GROUP BY Department_ID HAVING COUNT(Possition_ID) <= 1Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-06 : 04:03:23
|
| Thanks,but give me trigger or rule... to solve the problem |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-12-06 : 04:06:38
|
WelcomeVaibhav TIf I cant go back, I want to go fast... |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-12-06 : 04:09:25
|
| What is the need for trigger or rule ?For select Query ?Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-06 : 20:14:27
|
| I want: on my table (Department_ID nvarchar(2),Possition_ID nvarchar(2))never occur: exists SELECT Department_ID FROM MyTableWHERE Possition_ID = '00'GROUP BY Department_ID HAVING COUNT(Possition_ID) >= 2Help me the way |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-12-06 : 20:35:05
|
use UNIQUE Constraints KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-06 : 20:48:13
|
| "use UNIQUE Constraints"Help me more clearly,thanks |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-12-06 : 22:54:04
|
quote: Originally posted by ducletan "use UNIQUE Constraints"Help me more clearly,thanks
For example lets say that your existing table structure is as follows:Create table Test(Srno Int identity,Department_ID nvarchar(2),Possition_ID nvarchar(2) )Now you add a unique constraint on both the column. This will make sure that the combination key of Department_ID & Possition_ID is unique. You can read more on unique constraint in the link given by khtan.Alter table TestAdd constraint UK_Test Unique (Department_ID, Possition_ID) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-12-07 : 07:17:32
|
quote: Originally posted by ducletan "use UNIQUE Constraints"Help me more clearly,thanks
follow that link. there are clear explanation and examples in there. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|